示例#1
0
 public HttpRequest(HttpMethod method, Uri uri, HttpVersion version)
 {
     _allowAutoRedirect = true;
     _automaticDecompression = DecompressionMethods.None;
     _contentLength = -1L;
     _httpWriteMode = HttpWriteMode.Unknown;
     _keepAlive = true;
     _maximumResponseHeadersLength = 8190;
     _maxAutomaticRedirections = 50;
     _originUri = uri;
     _originMethod = method;
     _timeout = 100000;
     _uri = _originUri;
     _method = _originMethod;
     _version = version;
     _sendChunked = false;
     _headers = new HttpRequestHeaders();
     _startTimestamp = DateTime.UtcNow.Ticks;          
 }
示例#2
0
        /*++
            Uses an old Stream to resubmit buffered data using the current
             stream, this is used in cases of POST, or authentication,
             where we need to buffer upload data so that it can be resubmitted

            Input:

                OldStream - Old Stream that was previously used

            Returns:

                Nothing.

        --*/

        // 
        internal void ResubmitWrite(ConnectStream oldStream, bool suppressWrite) {
            GlobalLog.Enter("ConnectStream#" + ValidationHelper.HashString(this) + "::ResubmitWrite", ValidationHelper.HashString(oldStream));
            GlobalLog.ThreadContract(ThreadKinds.Sync, "ConnectStream#" + ValidationHelper.HashString(this) + "::ResubmitWrite");

            //
            // 




            //
            // we're going to resubmit
            //
            try {
                Interlocked.CompareExchange(ref m_CallNesting, Nesting.InternalIO, Nesting.Idle);
                GlobalLog.Print("ConnectStream#" + ValidationHelper.HashString(this) + "::ResubmitWrite() Inc: " + m_CallNesting.ToString());

                GlobalLog.Print("ConnectStream#" + ValidationHelper.HashString(this) + "::ResubmitWrite(), callNesting : " + m_CallNesting.ToString() + " IsClosed = " + IsClosed);
                //
                // no need to buffer here:
                // we're already resubmitting buffered data give it to the connection to put it on the wire again
                // we set BytesLeftToWrite to 0 'cause even on failure there can be no recovery,
                // so just leave it to IOError() to clean up and don't call ResubmitWrite()
                //
                ScatterGatherBuffers bufferedData = oldStream.BufferedData;
                SafeSetSocketTimeout(SocketShutdown.Send);
                if (!WriteChunked) {
                    if (!suppressWrite)
                        m_Connection.Write(bufferedData);
                }
                else {
                    // we have the data buffered, but we still want to chunk.

                    // first set this to disable Close() from sending a chunk terminator.
                    GlobalLog.Assert(m_HttpWriteMode != HttpWriteMode.None, "ConnectStream#{0}::ResubmitWrite()|m_HttpWriteMode == HttpWriteMode.None", ValidationHelper.HashString(this));
                    m_HttpWriteMode = HttpWriteMode.ContentLength;

                    if (bufferedData.Length==0) {
                        m_Connection.Write(NclConstants.ChunkTerminator, 0, NclConstants.ChunkTerminator.Length);
                    }
                    else {
                        int chunkHeaderOffset = 0;
                        byte[] chunkHeaderBuffer = GetChunkHeader(bufferedData.Length, out chunkHeaderOffset);
                        BufferOffsetSize[] dataBuffers = bufferedData.GetBuffers();
                        BufferOffsetSize[] buffers = new BufferOffsetSize[dataBuffers.Length + 3];
                        buffers[0] = new BufferOffsetSize(chunkHeaderBuffer, chunkHeaderOffset, chunkHeaderBuffer.Length - chunkHeaderOffset, false);
                        int index = 0;
                        foreach (BufferOffsetSize buffer in dataBuffers) {
                            buffers[++index] = buffer;
                        }
                        buffers[++index] = new BufferOffsetSize(NclConstants.CRLF, 0, NclConstants.CRLF.Length, false);
                        buffers[++index] = new BufferOffsetSize(NclConstants.ChunkTerminator, 0, NclConstants.ChunkTerminator.Length, false);

                        SplitWritesState splitState = new SplitWritesState(buffers);

                        BufferOffsetSize[] sendBuffers = splitState.GetNextBuffers();
                        while(sendBuffers != null){
                            m_Connection.MultipleWrite(sendBuffers);
                            sendBuffers = splitState.GetNextBuffers();
                        }
                    }
                }
                if(Logging.On && bufferedData.GetBuffers() != null) {
                    foreach (BufferOffsetSize bufferOffsetSize in bufferedData.GetBuffers()) {
                        if (bufferOffsetSize == null) {
                            Logging.Dump(Logging.Web, this, "ResubmitWrite", null, 0, 0);
                        }
                        else {
                            Logging.Dump(Logging.Web, this, "ResubmitWrite", bufferOffsetSize.Buffer, bufferOffsetSize.Offset, bufferOffsetSize.Size);
                        }
                    }
                }
                GlobalLog.Print("ConnectStream#" + ValidationHelper.HashString(this) + "::ResubmitWrite() sent:" + bufferedData.Length.ToString() );
            }
            catch (Exception exception)
            {
                if (NclUtilities.IsFatal(exception)) throw;

                // A Fatal error
                WebException we = new WebException(NetRes.GetWebStatusString("net_connclosed", WebExceptionStatus.SendFailure),
                                               WebExceptionStatus.SendFailure,
                                               WebExceptionInternalStatus.RequestFatal,
                                               exception);
                IOError(we, false);
            }
            finally {
                Interlocked.CompareExchange(ref m_CallNesting, Nesting.Idle, Nesting.InternalIO);
                GlobalLog.Print("ConnectStream#" + ValidationHelper.HashString(this) + "::ResubmitWrite(), callNesting : " + m_CallNesting.ToString() + " IsClosed = " + IsClosed);
            }
            m_BytesLeftToWrite = 0;
            CallDone();
            GlobalLog.Leave("ConnectStream#" + ValidationHelper.HashString(this) + "::ResubmitWrite", BytesLeftToWrite.ToString());
        }
示例#3
0
 internal void SwitchToContentLength(){
     m_HttpWriteMode = HttpWriteMode.ContentLength;
 }
示例#4
0
        /*++
            Write Constructor for this class. This is the write constructor;
            it takes as a parameter the amount of entity body data to be written,
            with a value of -1 meaning to write it out as chunked. The other
            parameter is the Connection of which we'll be writing.

            Right now we use the DefaultBufferSize for the stream. In
            the future we'd like to pass a 0 and have the stream be
            unbuffered for write.

            Input:

                Conn            - Connection for this stream.
                BytesToWrite    - Total bytes to be written, or -1
                                    if we're doing chunked encoding.

            Returns:

                Nothing.

        --*/

        public ConnectStream(Connection connection, HttpWebRequest request) {
            GlobalLog.Print("ConnectStream#" + ValidationHelper.HashString(this) + "::.ctor(Write)");
            m_Connection = connection;
            m_ReadTimeout = m_WriteTimeout = System.Threading.Timeout.Infinite;
            //
            // we need to save a reference to the request for two things
            // 1. In case of buffer-only we kick in actual submition when the stream is closed by a user
            // 2. In case of write stream abort() we notify the request so the response stream is handled properly
            //
            m_Request = request;
            m_HttpWriteMode = request.HttpWriteMode;

            GlobalLog.Assert(m_HttpWriteMode != HttpWriteMode.Unknown, "ConnectStream#{0}::.ctor()|HttpWriteMode:{1}", ValidationHelper.HashString(this), m_HttpWriteMode);
            m_BytesLeftToWrite = m_HttpWriteMode==HttpWriteMode.ContentLength ? request.ContentLength : -1;
            if (request.HttpWriteMode==HttpWriteMode.Buffer) {
                m_BufferOnly = true;
                EnableWriteBuffering();
            }
            GlobalLog.Print("ConnectStream#" + ValidationHelper.HashString(this) + "::.ctor() Connection:" + ValidationHelper.HashString(m_Connection) + " BytesToWrite:" + BytesLeftToWrite);

            m_ReadCallbackDelegate = new AsyncCallback(ReadCallback);
            m_WriteCallbackDelegate = new AsyncCallback(WriteCallback);
        }
示例#5
0
 private void CheckProtocol(bool requestedContent)
 {
     if (!HttpUtils.IsHttpUri(_uri))
     {
         throw new ProtocolException("Supports HTTP or HTTPS scheme.");
     }
     if (!_method.AllowRequestContent)
     {
         if (requestedContent)
         {
             throw new ProtocolViolationException("Cannot send a content-body with this method[" + _method + "]");
         }
         _httpWriteMode = HttpWriteMode.None;
     }
     else
     {
         if (_sendChunked)
         {                  
             _httpWriteMode = HttpWriteMode.Chunked;
         }
         else
         {
             _httpWriteMode = (_contentLength >= 0L) ? HttpWriteMode.ContentLength : (requestedContent ? HttpWriteMode.Buffer : HttpWriteMode.None);
         }
     }
     if (_httpWriteMode != HttpWriteMode.Chunked)
     {
         if (requestedContent && _contentLength == -1L && _keepAlive)
         {
             throw new ProtocolViolationException("Must either set ContentLength to a non-negative number or set SendChunked to true with this method[" + _originMethod + "]");
         }
     }
 }
 public void Reset()
 {
     m_requestSent = false;
     m_responseCreated = false;
     m_contentLength = -1;
     m_httpWriteMode = HttpWriteMode.None;
     m_httpRequestHeaders = new WebHeaderCollection(true);
 }
        /// <summary>
        /// Constructs an instance of the HTTP Protocol class and initalizes it
        /// to the basic header state.
        /// </summary>
        /// <param name="Url">The Url object for which we're creating.</param>
        internal HttpWebRequest(Uri Url)
        {
            m_requestSent = false;
            m_originalUrl = Url;
            SendChunked = false;
            m_keepAlive = true;
            m_httpRequestHeaders = new WebHeaderCollection(true);
            m_httpWriteMode = HttpWriteMode.None;

            m_contentLength = -1;
            m_version = HttpVersion.Version11;

            m_allowWriteStreamBuffering = false;

            Method = "GET";

            m_timeout = WebRequest.DefaultTimeout;
            m_readWriteTimeout = DefaultReadWriteTimeout;

            // set the default proxy initially (this can be overriden by the Proxy property)
            m_proxy = WebRequest.DefaultWebProxy;

            m_responseCreated = false;
        }
示例#8
0
        //
        // PERF:
        // removed some double initializations.
        // perf went from:
        // clocks per instruction CPI: 9,098.72 to 1,301.14
        // %app exclusive time: 2.92 to 0.43
        //
        /// <devdoc>
        ///    <para>
        ///       Basic Constructor for HTTP Protocol Class, Initializes to basic header state.
        ///    </para>
        /// </devdoc>
        internal HttpWebRequest(Uri uri, ServicePoint servicePoint)
        {
            if(Logging.On)Logging.Enter(Logging.Web, this, "HttpWebRequest", uri);

            (new WebPermission(NetworkAccess.Connect, uri)).Demand();

            // OOPS, This ctor can also be called with FTP scheme but then it should only allowed if going through the proxy
            // Something to think about...
            //if ((object)uri.Scheme != (object)Uri.UriSchemeHttp && (object)uri.Scheme != (object)Uri.UriSchemeHttps)
                //throw new ArgumentOutOfRangeException("uri");

            GlobalLog.Print("HttpWebRequest#" + ValidationHelper.HashString(this) + "::.ctor(" + uri.ToString() + ")");
            //
            // internal constructor, HttpWebRequest cannot be created directly
            // but only through WebRequest.Create() method
            // set defaults
            //
            _HttpRequestHeaders         = new WebHeaderCollection(WebHeaderCollectionType.HttpWebRequest);
            _Proxy                      = WebRequest.InternalDefaultWebProxy;
            _HttpWriteMode              = HttpWriteMode.Unknown;
            _MaximumAllowedRedirections = 50;
            _Timeout                    = WebRequest.DefaultTimeout;
            _TimerQueue                 = WebRequest.DefaultTimerQueue;
            _ReadWriteTimeout           = DefaultReadWriteTimeout;
            _MaximumResponseHeadersLength = DefaultMaximumResponseHeadersLength;
            _ContentLength              = -1;
            _OriginVerb                 = KnownHttpVerb.Get;
            _OriginUri                  = uri;
            _Uri                        = _OriginUri;
            _ServicePoint               = servicePoint;
            _RequestIsAsync             = TriState.Unspecified;

            SetupCacheProtocol(_OriginUri);

            if(Logging.On)Logging.Exit(Logging.Web, this, "HttpWebRequest", null);
        }
示例#9
0
        internal HttpWebRequest(Uri uri, ServicePoint servicePoint) {
            if(Logging.On)Logging.Enter(Logging.Web, this, "HttpWebRequest", uri);

            CheckConnectPermission(uri, false);

            m_StartTimestamp = NetworkingPerfCounters.GetTimestamp();
            NetworkingPerfCounters.Instance.Increment(NetworkingPerfCounterName.HttpWebRequestCreated);

            // OOPS, This ctor can also be called with FTP scheme but then it should only allowed if going through the proxy
            // Something to think about...
            //if ((object)uri.Scheme != (object)Uri.UriSchemeHttp && (object)uri.Scheme != (object)Uri.UriSchemeHttps)
                //throw new ArgumentOutOfRangeException("uri");

            GlobalLog.Print("HttpWebRequest#" + ValidationHelper.HashString(this) + "::.ctor(" + uri.ToString() + ")");
            //
            // internal constructor, HttpWebRequest cannot be created directly
            // but only through WebRequest.Create() method
            // set defaults
            //
            _HttpRequestHeaders         = new WebHeaderCollection(WebHeaderCollectionType.HttpWebRequest);
            _Proxy                      = WebRequest.InternalDefaultWebProxy;
            _HttpWriteMode              = HttpWriteMode.Unknown;
            _MaximumAllowedRedirections = 50;
            _Timeout                    = WebRequest.DefaultTimeout;
            _TimerQueue                 = WebRequest.DefaultTimerQueue;
            _ReadWriteTimeout           = DefaultReadWriteTimeout;
            _MaximumResponseHeadersLength = DefaultMaximumResponseHeadersLength;
            _ContentLength              = -1;
            _originalContentLength      = -1;
            _OriginVerb                 = KnownHttpVerb.Get;
            _OriginUri                  = uri;
            _Uri                        = _OriginUri;
            _ServicePoint               = servicePoint;
            _RequestIsAsync             = TriState.Unspecified;
            m_ContinueTimeout          = DefaultContinueTimeout;
            m_ContinueTimerQueue        = s_ContinueTimerQueue;

            SetupCacheProtocol(_OriginUri);

#if HTTP_HEADER_EXTENSIONS_SUPPORTED
            _NextExtension      = 10;
#endif // HTTP_HEADER_EXTENSIONS_SUPPORTED

            if(Logging.On)Logging.Exit(Logging.Web, this, "HttpWebRequest", null);
        }
示例#10
0
        /*
            Accessor:   BeginGetRequestStream

            Retreives the Request Stream from an HTTP Request uses an Async
              operation to do this, and the result is retrived async.

            Async operations include work in progess, this call is used to retrieve
             results by pushing the async operations to async worker thread on the callback.
            There are many open issues involved here including the handling of possible blocking
            within the bounds of the async worker thread or the case of Write and Read stream
            operations still blocking.


            Input:

            Returns: The Async Result


        */
        /// <include file='doc\HttpWebRequest.uex' path='docs/doc[@for="HttpWebRequest.BeginGetRequestStream"]/*' />
        /// <devdoc>
        ///    <para>[To be supplied.]</para>
        /// </devdoc>
        public override IAsyncResult BeginGetRequestStream(AsyncCallback callback, object state) {
            GlobalLog.Enter("HttpWebRequest#" + ValidationHelper.HashString(this) + "::BeginGetRequestStream");

            if (!CanGetRequestStream) {
                throw new ProtocolViolationException(SR.GetString(SR.net_nouploadonget));
            }

            // prevent someone from trying to send data without setting
            // a ContentLength or SendChunked when buffering is disabled and on a KeepAlive connection
            if (MissingEntityBodyDelimiter) {
                throw new ProtocolViolationException(SR.GetString(SR.net_contentlengthmissing));
            }

            // prevent someone from setting a Transfer Encoding without having SendChunked=true
            if (TransferEncodingWithoutChunked) {
                throw new InvalidOperationException(SR.GetString(SR.net_needchunked));
            }

            // used to make sure the user issues a GetRequestStream before GetResponse
            _WriteStreamRetrieved = true;

            Monitor.Enter(this);

            if (_WriteAResult != null) {

                Monitor.Exit(this);

                throw new InvalidOperationException(SR.GetString(SR.net_repcall));
            }

            // get async going
            LazyAsyncResult asyncResult =
                new LazyAsyncResult(
                    this,
                    state,
                    callback );

            _WriteAResult = asyncResult;
            Monitor.Exit(this);

            //
            // See if we're already submitted a request.
            //
            if (_RequestSubmitted) {
                // We already have. Make sure we have a write stream.
                if (_SubmitWriteStream != null) {
                    // It was, just return the stream.
                    try {
                        asyncResult.InvokeCallback(true, _SubmitWriteStream);
                    }
                    catch {
                        Abort();
                        throw;
                    }

                    goto done;
                }
                else {
                    //
                    // No write stream, this is an application error.
                    //
                    if (_ResponseException!=null) {
                        //
                        // somebody already aborted for some reason
                        // rethrow for the same reason
                        //
                        throw _ResponseException;
                    }
                    else {
                        throw new InvalidOperationException(SR.GetString(SR.net_reqsubmitted));
                    }
                }
            }

            // OK, we haven't submitted the request yet, so do so
            // now.
            //

            // prevent new requests when low on resources
            if (System.Net.Connection.IsThreadPoolLow()) {
                throw new InvalidOperationException(SR.GetString(SR.net_needmorethreads));
            }

            if (_HttpWriteMode == HttpWriteMode.None) {
                _HttpWriteMode = HttpWriteMode.Write;
            }

            // save off verb from origin Verb
            GlobalLog.Print("HttpWebRequest#"+ValidationHelper.HashString(this)+": setting _Verb to _OriginVerb ["+_OriginVerb+"]");
            _Verb = _OriginVerb;
            BeginSubmitRequest(false);

done:
            GlobalLog.Leave("HttpWebRequest#" + ValidationHelper.HashString(this) + "::BeginGetRequestStream", ValidationHelper.HashString(asyncResult));
            return asyncResult;
        }
示例#11
0
 internal void SetContentLength(long contentLength) {
     _ContentLength = contentLength;
     _HttpWriteMode = HttpWriteMode.Write;
 }
示例#12
0
        /*++

        Routine Description:

            CheckResubmit - Determines if a HTTP request needs to be
              resubmitted to a server point, this is called in Response
              Parsing to handle cases such as server Redirects,
              und Authentication

        Arguments:

            None.

        Return Value:

            true  - if we should reattempt submitting the request
            false - if the request is complete

        --*/
        private bool CheckResubmit() {
            GlobalLog.Enter("CheckResubmit");

            GlobalLog.Print("HttpWebRequest#" + ValidationHelper.HashString(this) + "::CheckResubmit()");

            if (ResponseStatusCode==HttpStatusCode.Unauthorized                 || // 401
                ResponseStatusCode==HttpStatusCode.ProxyAuthenticationRequired) {  // 407
                //
                // Check for Authentication
                //
                if (!CheckResubmitForAuth()) {
                    GlobalLog.Leave("CheckResubmit");
                    return false;
                }
            }
            else {
                //
                // Check for Redirection
                //
                // Table View:
                // Method            301             302             303             307
                //    *                *               *             GET               *
                // POST              GET             GET             GET            POST
                //
                // Put another way:
                //  301 & 302  - All methods are redirected to the same method but POST. POST is redirected to a GET.
                //  303 - All methods are redirected to GET
                //  307 - All methods are redirected to the same method.
                //

                if (_AllowAutoRedirect && (
                    ResponseStatusCode==HttpStatusCode.Ambiguous          || // 300
                    ResponseStatusCode==HttpStatusCode.Moved              || // 301
                    ResponseStatusCode==HttpStatusCode.Redirect           || // 302
                    ResponseStatusCode==HttpStatusCode.RedirectMethod     || // 303
                    ResponseStatusCode==HttpStatusCode.RedirectKeepVerb)) {  // 307

                    _AutoRedirects += 1;
                    if (_AutoRedirects > _MaximumAllowedRedirections) {
                        GlobalLog.Leave("CheckResubmit");
                        return false;
                    }

                    string Location = _HttpResponse.Headers["Location"];
                    string newMethod = _Verb;
                    bool DisableUpload = false;

                    switch (ResponseStatusCode) {
                        case HttpStatusCode.Moved:
                        case HttpStatusCode.Redirect:
                            if (string.Compare(newMethod, "POST", true, CultureInfo.InvariantCulture) == 0) {
                                newMethod = "GET";
                                DisableUpload = true;
                            }
                            break;

                        case HttpStatusCode.RedirectKeepVerb:
                            break;

                        case HttpStatusCode.RedirectMethod:
                        default:
                            DisableUpload = true;
                            newMethod = "GET";
                            break;
                    }

                    GlobalLog.Print("Location = " + Location);

                    if (Location != null) {
                        // set possible new Method
                        GlobalLog.Print("HttpWebRequest#"+ValidationHelper.HashString(this)+": changing Verb from "+_Verb+" to "+newMethod);
                        _Verb = newMethod;
                        if (DisableUpload) {
                            GlobalLog.Print("HttpWebRequest#"+ValidationHelper.HashString(this)+": disabling upload");
                            _ContentLength = -1;
                            _HttpWriteMode = HttpWriteMode.None;
                            _SubmitWriteStream = null;
                        }

                        Uri previousUri = _Uri;

                        try {
                            _Uri = new Uri(_Uri, Location, true);
                        }
                        catch (Exception exception) {
                            _ResponseException = new WebException(SR.GetString(SR.net_resubmitprotofailed),
                                                               exception,
                                                               WebExceptionStatus.ProtocolError,
                                                               _HttpResponse
                                                              );
                            GlobalLog.Leave("CheckResubmit");
                            return false;
                        }

                        if (_Uri.Scheme != Uri.UriSchemeHttp &&
                            _Uri.Scheme != Uri.UriSchemeHttps) {
                            _ResponseException = new WebException(SR.GetString(SR.net_resubmitprotofailed),
                                                               null,
                                                               WebExceptionStatus.ProtocolError,
                                                               _HttpResponse
                                                              );

                            GlobalLog.Leave("CheckResubmit");
                            return false;  // can't handle these redirects
                        }

                        try {
                            //Check for permissions against redirect Uri
                            (new WebPermission(NetworkAccess.Connect, _Uri.AbsoluteUri)).Demand();
                        }
                        catch {
                            // We are on other thread.
                            // Don't let the thread die but pass the error on to the user thread.
                            _ResponseException = new SecurityException(SR.GetString(SR.net_redirect_perm),
                                                                    new WebException(SR.GetString(SR.net_resubmitcanceled),
                                                                    null,
                                                                    WebExceptionStatus.ProtocolError,
                                                                    _HttpResponse)
                                                                    );
                            GlobalLog.Leave("CheckResubmit");
                            return false;
                        }

                        //
                        // make sure we're not sending over credential information to an evil redirection
                        // URI. this will set our credentials to null unless the user is using DefaultCredentials
                        // or a CredentialCache, in which case he is responsible for binding the credentials to
                        // the proper Uri and AuthenticationScheme.
                        //

                        ICredentials authTemp = _AuthInfo as CredentialCache;

                        if (authTemp==null) {
                            //
                            // if it's not a CredentialCache it could still be DefaultCredentials
                            // check for this case as well
                            //
                            _AuthInfo = _AuthInfo as SystemNetworkCredential;
                        }
                        else {
                            _AuthInfo = authTemp;
                        }

                        //
                        // do the necessary cleanup on the Headers involved in the
                        // Authentication handshake.
                        //
                        _ProxyAuthenticationState.ClearAuthReq(this);
                        _ServerAuthenticationState.ClearAuthReq(this);

                        GlobalLog.Print("HttpWebRequest#"+ValidationHelper.HashString(this)+": _Verb="+_Verb);
                        // resubmit
                    }
                    else {
                        GlobalLog.Leave("CheckResubmit");
                        return false;
                    }
                }
                else { // if (_AllowAutoRedirect)
                    GlobalLog.Leave("CheckResubmit");
                    return false;
                }
            } // else

            if ((_HttpWriteMode != HttpWriteMode.None) && !AllowWriteStreamBuffering && _ContentLength != 0) {
                _ResponseException = new WebException(SR.GetString(SR.net_need_writebuffering),
                                                        null,
                                                        WebExceptionStatus.ProtocolError,
                                                        _HttpResponse);


                GlobalLog.Leave("CheckResubmit");
                return false;
            }

            if (System.Net.Connection.IsThreadPoolLow()) {
                _ResponseException = new InvalidOperationException(SR.GetString(SR.net_needmorethreads));
                return false;
            }

            GlobalLog.Leave("CheckResubmit");
            return true;
        }
示例#13
0
        protected HttpWebRequest(SerializationInfo serializationInfo, StreamingContext streamingContext) {
            
            new WebPermission(PermissionState.Unrestricted).Demand();

            _HttpRequestHeaders = (WebHeaderCollection)serializationInfo.GetValue("_HttpRequestHeaders", typeof(WebHeaderCollection));
            _Proxy                      = (IWebProxy)serializationInfo.GetValue("_Proxy", typeof(IWebProxy));
            _KeepAlive                  = serializationInfo.GetBoolean("_KeepAlive");
            _Pipelined                  = serializationInfo.GetBoolean("_Pipelined");
            _AllowAutoRedirect          = serializationInfo.GetBoolean("_AllowAutoRedirect");
            _AllowWriteStreamBuffering  = serializationInfo.GetBoolean("_AllowWriteStreamBuffering");
            _HttpWriteMode              = (HttpWriteMode)serializationInfo.GetInt32("_HttpWriteMode");
            _MaximumAllowedRedirections = serializationInfo.GetInt32("_MaximumAllowedRedirections");
            _AutoRedirects              = serializationInfo.GetInt32("_AutoRedirects");
            _Timeout                    = serializationInfo.GetInt32("_Timeout");
            _ContentLength              = serializationInfo.GetInt64("_ContentLength");
            _MediaType                  = serializationInfo.GetString("_MediaType");
            _OriginVerb                 = serializationInfo.GetString("_OriginVerb");
            _ConnectionGroupName        = serializationInfo.GetString("_ConnectionGroupName");
            _Version                    = (Version)serializationInfo.GetValue("_Version", typeof(Version));
            _OriginUri                  = (Uri)serializationInfo.GetValue("_OriginUri", typeof(Uri));

            CreateDefaultObjects();
        }
示例#14
0
        /*++

        Routine Description:

            Basic Constructor for HTTP Protocol Class,
              initalizes to basic header state.

        Arguments:

            Uri     - Uri object for which we're creating.

        Return Value:

            None.

        --*/
        //
        // PERF:
        // removed some double initializations.
        // perf went from:
        // clocks per instruction CPI: 9,098.72 to 1,301.14
        // %app exclusive time: 2.92 to 0.43
        //
        internal HttpWebRequest(Uri uri) {
            GlobalLog.Print("HttpWebRequest#" + ValidationHelper.HashString(this) + "::.ctor(" + uri.ToString() + ")");
            //
            // internal constructor, HttpWebRequest cannot be created directly
            // but only through WebRequest.Create() method
            // set defaults
            //
            _HttpRequestHeaders         = new WebHeaderCollection(true);
            _Proxy                      = GlobalProxySelection.SelectInternal;
            _KeepAlive                  = true;
            _Pipelined                  = true;
            _AllowAutoRedirect          = true;
            _AllowWriteStreamBuffering  = true;
            _HttpWriteMode              = HttpWriteMode.None;
            _MaximumAllowedRedirections = 50;
            _Timeout                    = WebRequest.DefaultTimeout;
            _ContentLength              = -1;
            _OriginVerb                 = "GET";
            _Verb                       = _OriginVerb;
            _Version                    = HttpVersion.Version11;
            _OriginUri                  = uri;

            CreateDefaultObjects();
        }