How robbiehanson/cocoahttpserver works
CocoaHTTPServer is an embeddable HTTP server for macOS and iOS. A client connects to the listener; the server accepts connections and the connection layer handles HTTP exchanges, including response streaming. The response protocol supports ranged and asynchronous output, with file and dynamic-file response implementations. The README also documents Bonjour, password protection, SSL/TLS, WebSockets and WebDAV; these are preserved as capability branches. Source excerpts are limited, so several implementation links are unverified or omitted.
Main entry points: HTTPConnection.m HTTP connection · HTTPServer.m HTTP listener · HTTPAsyncFileResponse.m Async file response · DAVConnection.m WebDAV connection
Components 17
Server and transport
- HTTP listener
Core/HTTPServer.m - Bonjour discovery
Core/HTTPServer.m
HTTP exchange
- HTTP connection
Core/HTTPConnection.m - HTTP messages
Core/HTTPMessage.m - Authentication
Core/HTTPAuthenticationRequest.m - Multipart parsing
Core/Mime/MultipartFormDataParser.m - Multipart headers
Core/Mime/MultipartMessageHeader.m
Response delivery
- Response contract
Core/HTTPResponse.h - Async file response
Core/Responses/HTTPAsyncFileResponse.m - Dynamic file response
Core/Responses/HTTPDynamicFileResponse.m - File and data responses
Core/Responses/HTTPFileResponse.m - Error and redirect responses
Core/Responses/HTTPErrorResponse.m
Protocols and extensions
- WebSocket
Core/WebSocket.m - WebDAV connection
Extensions/WebDAV/DAVConnection.m - WebDAV responses
Extensions/WebDAV/DAVResponse.m - TLS support
Core/HTTPConnection.m
Other components
- HTTP client
Connections 12
- HTTP client → HTTP listener: connects to
README.markdown - HTTP listener → Bonjour discovery: publishes service
- HTTP listener → HTTP connection: creates handler
- HTTP connection → Response contract: requests response data
Core/HTTPResponse.h - Multipart parsing → Multipart headers: parses part headers
- Async file response → HTTP connection: notifies new data
- Dynamic file response → Async file response: extends file streaming
- HTTP connection → TLS support: supports encryption
README.markdown - HTTP listener → WebSocket: supports WebSockets
README.markdown - HTTP connection → WebDAV connection: supports WebDAV
README.markdown - WebDAV connection → WebDAV responses: uses responses
- HTTP connection → Authentication: supports passwords
README.markdown