11 - implements nsIProtocolHandler
13 - owns the authentication cache
14 - holds references to frequently used services
17 - implements nsIHttpChannel
19 - initiates http transactions
20 - processes http response codes
21 - intercepts progress notifications
24 - implements nsIStreamListener & nsIStreamProvider
25 - talks to the socket transport service
26 - feeds data to its transaction object
27 - routes progress notifications
30 - identifies a connection
33 - implements nsIRequest
34 - encapsulates a http request and response
35 - parses incoming data
38 - owned by a transaction
39 - removes chunked decoding
42 - owns a nsHttpHeaderArray
43 - knows how to fill a request buffer
46 - owns a nsHttpHeaderArray
47 - knows how to parse response lines
48 - performs common header manipulations/calculations
51 - stores http "<header>:<value>" pairs
54 - stores authentication credentials for http auth domains
57 - implements nsIHttpAuthenticator
58 - generates BASIC auth credentials from user:pass
63 nsHttp:: (header namespace)
65 eg. nsHttp::Content_Length
70 InitiateTransaction -> ActivateConnection -> AsyncWrite, AsyncRead
72 The channel creates transactions, and passes them to the handler via
73 InitiateTransaction along with a nsHttpConnectionInfo object
74 identifying the requested connection. The handler either dispatches
75 the transaction immediately or queues it up to be dispatched later,
76 depending on whether or not the limit on the number of connections
77 to the requested server has been reached. Once the transaction can
78 be run, the handler looks for an idle connection or creates a new
79 connection, and then (re)activates the connection, assigning it the
82 Once activated the connection ensures that it has a socket transport,
83 and then calls AsyncWrite and AsyncRead on the socket transport. This
84 begins the process of talking to the server. To minimize buffering,
85 socket transport thread-proxying is completely disabled (using the flags
86 DONT_PROXY_LISTENER | DONT_PROXY_PROVIDER | DONT_PROXY_OBSERVER with
87 both AsyncWrite and AsyncRead). This means that the nsHttpConnection's
88 OnStartRequest, OnDataAvailable, OnDataWritable, and OnStopRequest
89 methods will execute on the socket transport thread.
91 The transaction defines (non-virtual) OnDataReadable, OnDataWritable, and
92 OnStopTransaction methods, which the connection calls in response to
93 its OnDataAvailable, OnDataWritable, and OnStopRequest methods, respectively.
94 The transaction owns a nsStreamListenerProxy created by the channel, which
95 it uses to transfer data from the socket thread over to the client's thread.
96 To mimize buffering, the transaction implements nsIInputStream, and passes
97 itself to the stream listener proxy's OnDataAvailable. In this way, we
98 have effectively wedged the response parsing between the socket and the
99 thread proxy's buffer. When read, the transaction turns around and reads
100 from the socket using the buffer passed to it. The transaction scans the
101 buffer for headers, removes them as they are detected, and copies the headers
102 into its nsHttpResponseHead object. The rest of the data remains in the
103 buffer, and is proxied over to the client's thread to be handled first by the
104 http channel and eventually by the client.
106 There are several other major design factors, including:
108 - transaction cancelation
109 - progress notification
113 - premature EOF detection and transaction restarting
114 - pipelining (not yet implemented)