示例#1
0
 internal HttpListenerResponse()
 {
     if (Logging.On)
     {
         Logging.PrintInfo(Logging.HttpListener, this, ".ctor", "");
     }
     this.m_NativeResponse                      = new UnsafeNclNativeMethods.HttpApi.HTTP_RESPONSE();
     this.m_WebHeaders                          = new WebHeaderCollection(WebHeaderCollectionType.HttpListenerResponse);
     this.m_BoundaryType                        = System.Net.BoundaryType.None;
     this.m_NativeResponse.StatusCode           = 200;
     this.m_NativeResponse.Version.MajorVersion = 1;
     this.m_NativeResponse.Version.MinorVersion = 1;
     this.m_KeepAlive     = true;
     this.m_ResponseState = ResponseState.Created;
 }
示例#2
0
 public void CopyFrom(HttpListenerResponse templateResponse)
 {
     if (Logging.On)
     {
         Logging.PrintInfo(Logging.HttpListener, this, "CopyFrom", "templateResponse#" + ValidationHelper.HashString(templateResponse));
     }
     this.m_NativeResponse                      = new UnsafeNclNativeMethods.HttpApi.HTTP_RESPONSE();
     this.m_ResponseState                       = ResponseState.Created;
     this.m_WebHeaders                          = templateResponse.m_WebHeaders;
     this.m_BoundaryType                        = templateResponse.m_BoundaryType;
     this.m_ContentLength                       = templateResponse.m_ContentLength;
     this.m_NativeResponse.StatusCode           = templateResponse.m_NativeResponse.StatusCode;
     this.m_NativeResponse.Version.MajorVersion = templateResponse.m_NativeResponse.Version.MajorVersion;
     this.m_NativeResponse.Version.MinorVersion = templateResponse.m_NativeResponse.Version.MinorVersion;
     this.m_StatusDescription                   = templateResponse.m_StatusDescription;
     this.m_KeepAlive = templateResponse.m_KeepAlive;
 }
示例#3
0
 internal UnsafeNclNativeMethods.HttpApi.HTTP_FLAGS ComputeHeaders()
 {
     UnsafeNclNativeMethods.HttpApi.HTTP_FLAGS nONE = UnsafeNclNativeMethods.HttpApi.HTTP_FLAGS.NONE;
     this.m_ResponseState = ResponseState.ComputedHeaders;
     if ((this.HttpListenerContext.MutualAuthentication != null) && (this.HttpListenerContext.MutualAuthentication.Length > 0))
     {
         this.Headers.SetInternal(HttpResponseHeader.WwwAuthenticate, this.HttpListenerContext.MutualAuthentication);
     }
     this.ComputeCookies();
     if (this.m_BoundaryType == System.Net.BoundaryType.None)
     {
         if (this.HttpListenerRequest.ProtocolVersion.Minor == 0)
         {
             this.m_KeepAlive = false;
         }
         else
         {
             this.m_BoundaryType = System.Net.BoundaryType.Chunked;
         }
         if (this.CanSendResponseBody(this.m_HttpContext.Response.StatusCode))
         {
             this.m_ContentLength = -1L;
         }
         else
         {
             this.ContentLength64 = 0L;
         }
     }
     if (this.m_BoundaryType == System.Net.BoundaryType.ContentLength)
     {
         this.Headers.SetInternal(HttpResponseHeader.ContentLength, this.m_ContentLength.ToString("D", NumberFormatInfo.InvariantInfo));
         if (this.m_ContentLength == 0L)
         {
             nONE = UnsafeNclNativeMethods.HttpApi.HTTP_FLAGS.NONE;
         }
     }
     else if (this.m_BoundaryType == System.Net.BoundaryType.Chunked)
     {
         this.Headers.SetInternal(HttpResponseHeader.TransferEncoding, "chunked");
     }
     else if (this.m_BoundaryType == System.Net.BoundaryType.None)
     {
         nONE = UnsafeNclNativeMethods.HttpApi.HTTP_FLAGS.NONE;
     }
     else
     {
         this.m_KeepAlive = false;
     }
     if (!this.m_KeepAlive)
     {
         this.Headers.Add(HttpResponseHeader.Connection, "close");
         if (nONE == UnsafeNclNativeMethods.HttpApi.HTTP_FLAGS.NONE)
         {
             nONE = UnsafeNclNativeMethods.HttpApi.HTTP_FLAGS.HTTP_INITIALIZE_SERVER;
         }
         return(nONE);
     }
     if (this.HttpListenerRequest.ProtocolVersion.Minor == 0)
     {
         this.Headers.SetInternal(HttpResponseHeader.KeepAlive, "true");
     }
     return(nONE);
 }