Container for a HTTP status line, i.e. the first line of a HTTP response
Ejemplo n.º 1
0
 /// <summary>
 /// HTTPステータス、ヘッダ、ボディを元に初期化。
 /// </summary>
 /// <param name="statusLine">HTTPステータスライン。</param>
 /// <param name="headers">HTTPレスポンスヘッダ。</param>
 /// <param name="body">HTTPレスポンスボディ。</param>
 public HttpResponse(HttpStatusLine statusLine, HttpHeaders headers, byte[] body)
 {
     this.StatusLine = statusLine;
     this.Headers = headers;
     this.Body = body;
 }
Ejemplo n.º 2
0
        /// <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(SocketPS);
            ResponseHeaders = new HttpHeaders(SocketPS);

            // Get bPersistConnectionPS (RFC 2616, section 14.10)
            bool bUseDefaultPersistPS = true;
            if (ResponseHeaders.Connection != null)
                foreach (var item in ResponseHeaders.Connection)
                {
                    if (item.Equals("close"))
                    {
                        State.bPersistConnectionPS = false;
                        bUseDefaultPersistPS = false;
                        break;
                    }
                    if (item.Equals("keep-alive"))
                    {
                        State.bPersistConnectionPS = true;
                        bUseDefaultPersistPS = false;
                        break;
                    }
                }
            if (bUseDefaultPersistPS)
                State.bPersistConnectionPS =
                    (!ResponseStatusLine.ProtocolVersion.Equals("1.0"));

            if (State.bPersistConnectionPS)
                SocketPS.KeepAlive = true;
            else
                State.bPersistConnectionBP = false;

            State.NextStep = SendResponse;
            OnReceiveResponse();
        }