feat: unify HTTP server across iOS/tvOS/watchOS on Network.framework - #1221
Merged
Conversation
Extends the Network.framework-based HTTP server built for watchOS (which can't use BSD sockets) to iOS and tvOS as well, replacing the vendored CocoaAsyncSocket/CocoaHTTPServer/RoutingHTTPServer stack (~22k lines) with the ~600-line implementation already proven in production on watchOS. FBWatchHTTPServer is renamed to FBHTTPServer and moved out of the watchOS-specific directory since it's now the only implementation; custom bind-IP support (previously iOS/tvOS-only via setInterface:) is added to FBTCPSocket via Network.framework so it works on all three platforms. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
KazuCocoa
approved these changes
Aug 22, 2026
github-actions Bot
pushed a commit
that referenced
this pull request
Aug 22, 2026
## [16.7.0](v16.6.0...v16.7.0) (2026-08-22) ### Features * unify HTTP server across iOS/tvOS/watchOS on Network.framework ([#1221](#1221)) ([cd741c5](cd741c5))
|
🎉 This PR is included in version 16.7.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
This was referenced Aug 22, 2026
mykola-mokhnach
added a commit
that referenced
this pull request
Aug 23, 2026
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>
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.
Summary
FBWatchHTTPServertoFBHTTPServerand move it (withRouteRequest/RouteResponse) out of the watchOS-specific directory intoRouting/, since it's now the single implementation for all platforms.FBTCPSocketvia Network.framework (nw_parameters_set_local_endpoint), restoring thesetInterface:capability that was previously iOS/tvOS-only.WebDriverAgentLib/Vendor/entirely and updateproject.pbxprojaccordingly.