Skip to content

feat: unify HTTP server across iOS/tvOS/watchOS on Network.framework - #1221

Merged
mykola-mokhnach merged 1 commit into
masterfrom
server
Aug 22, 2026
Merged

feat: unify HTTP server across iOS/tvOS/watchOS on Network.framework#1221
mykola-mokhnach merged 1 commit into
masterfrom
server

Conversation

@mykola-mokhnach

Copy link
Copy Markdown

Summary

  • Replace the vendored CocoaAsyncSocket/CocoaHTTPServer/RoutingHTTPServer stack (~22k lines) with the Network.framework-based HTTP server already built for watchOS (which can't use BSD sockets), now shared by iOS, tvOS, and watchOS.
  • Rename FBWatchHTTPServer to FBHTTPServer and move it (with RouteRequest/RouteResponse) out of the watchOS-specific directory into Routing/, since it's now the single implementation for all platforms.
  • Add custom bind-IP support to FBTCPSocket via Network.framework (nw_parameters_set_local_endpoint), restoring the setInterface: capability that was previously iOS/tvOS-only.
  • Delete WebDriverAgentLib/Vendor/ entirely and update project.pbxproj accordingly.

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>
@mykola-mokhnach
mykola-mokhnach merged commit cd741c5 into master Aug 22, 2026
60 checks passed
@mykola-mokhnach
mykola-mokhnach deleted the server branch August 22, 2026 19:40
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))
@github-actions

Copy link
Copy Markdown

🎉 This PR is included in version 16.7.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants