/// <summary> /// Pipeline step: read the HTTP response from the local client, /// schedule the next step to be <c>SendResponse</c>, and call /// <c>OnReceiveResponse</c> /// </summary> protected virtual void ReadResponse() { // Wait until we receive the response, then parse its header ResponseStatusLine = new HttpStatusLine(RemoteSocket); ResponseHeaders = new HttpHeaders(RemoteSocket); // Get PersistConnectionRemoteSocket (RFC 2616, section 14.10) bool bUseDefaultPersistPS = true; if (ResponseHeaders.Connection != null) { foreach (var item in ResponseHeaders.Connection) { if (item.Equals("close")) { State.PersistConnectionRemoteSocket = false; bUseDefaultPersistPS = false; break; } if (item.Equals("keep-alive")) { State.PersistConnectionRemoteSocket = true; bUseDefaultPersistPS = false; break; } } } if (bUseDefaultPersistPS) { State.PersistConnectionRemoteSocket = (ResponseStatusLine.ProtocolVersion.Equals("1.0") == false); } if (State.PersistConnectionRemoteSocket) { RemoteSocket.KeepAlive = true; } else { State.PersistConnectionBrowserSocket = false; } State.NextStep = SendResponse; }