fix: harden FBHTTPServer/FBTCPSocket against races and protocol gaps - #1224
Open
mykola-mokhnach wants to merge 1 commit into
Open
fix: harden FBHTTPServer/FBTCPSocket against races and protocol gaps#1224mykola-mokhnach wants to merge 1 commit into
mykola-mokhnach wants to merge 1 commit into
Conversation
|
Looks like there are some merge conflicts |
Follow-up fixes for the Network.framework HTTP server (#1221) found while porting it to a downstream WebDriverAgent fork: - Defer FBWebServer's shutdown delegate call so the /wda/shutdown response is actually written before the socket/connections are torn down. - Cancel FBTCPSocket connections on the socket queue during -stop so an already-issued write isn't raced by the cancellation. - Cancel the listener on startup timeout/failure instead of just dropping the reference, and surface POSIX errors (e.g. EADDRINUSE) undecorated so FBWebServer's port-retry check can match them. - Stop accumulating received data via repeated mutableCopy+append (O(n^2)); append into a single NSMutableData instead. - Cache parsed request headers per connection while the body streams in, instead of re-scanning/re-parsing the whole buffered header block on every incoming chunk. - Remove a client's buffered state before responding with a terminal error (413/400/501) so a still-streaming body can't re-trigger the same response. - Reject Transfer-Encoding: chunked explicitly (501) instead of silently treating the request as bodyless and desyncing the connection. - Apply default headers (CORS, Server) to error responses, not just successfully-routed ones. - Give multiple "*" wildcard segments in one route path distinct params keys instead of overwriting a single "wildcards" key. - Return valid WebDriver protocol error JSON for 400/404/413/501 responses instead of raw strings, matching the shape route handlers already use. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Author
conflict resolved |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up fixes for the Network.framework HTTP server (#1221) found while porting it to a downstream WebDriverAgent fork: