/// <summary> /// Gets the request stream /// </summary> /// <returns>The request stream</returns> /// <param name="contentlength">The content length to use</param> public Stream GetRequestStream(long contentlength = -1) { // Prevent in-memory buffering causing out-of-memory issues if (this.m_request is HttpWebRequest request) { if (contentlength >= 0) { request.ContentLength = contentlength; } if (request.ContentLength >= 0) { request.AllowWriteStreamBuffering = false; } } if (m_state == RequestStates.GetRequest) { return((Stream)m_asyncRequest.GetResponseOrStream()); } if (m_state != RequestStates.Created) { throw new InvalidOperationException(); } m_asyncRequest = new AsyncWrapper(this, true); m_state = RequestStates.GetRequest; return(TrySetTimeout((Stream)m_asyncRequest.GetResponseOrStream(), m_activity_timeout)); }
/// <summary> /// Gets the request stream /// </summary> /// <returns>The request stream</returns> public Stream GetRequestStream() { if (m_state == RequestStates.GetRequest) { return((Stream)m_asyncRequest.GetResponseOrStream()); } if (m_state != RequestStates.Created) { throw new InvalidOperationException(); } m_asyncRequest = new AsyncWrapper(this, true); m_state = RequestStates.GetRequest; return(TrySetTimeout((Stream)m_asyncRequest.GetResponseOrStream(), m_activity_timeout)); }
/// <summary> /// Gets the response object /// </summary> /// <returns>The web response</returns> public WebResponse GetResponse() { if (m_state == RequestStates.GetResponse) { return((WebResponse)m_asyncResponse.GetResponseOrStream()); } if (m_state == RequestStates.Done) { throw new InvalidOperationException(); } m_asyncRequest = null; m_asyncResponse = new AsyncWrapper(this, false); m_state = RequestStates.GetResponse; return((WebResponse)m_asyncResponse.GetResponseOrStream()); }
/// <summary> /// Gets the request stream /// </summary> /// <returns>The request stream</returns> public Stream GetRequestStream() { if (m_state == RequestStates.GetRequest) { return((Stream)m_asyncRequest.GetResponseOrStream()); } if (m_state != RequestStates.Created) { throw new InvalidOperationException(); } m_asyncRequest = new AsyncWrapper(this, true); m_state = RequestStates.GetRequest; var s = (Stream)m_asyncRequest.GetResponseOrStream(); try { s.WriteTimeout = m_activity_timeout; } catch { } return(s); }
/// <summary> /// Gets the response object /// </summary> /// <returns>The web response</returns> public WebResponse GetResponse() { if (m_state == RequestStates.GetResponse) return (WebResponse)m_asyncResponse.GetResponseOrStream(); if (m_state == RequestStates.Done) throw new InvalidOperationException(); m_asyncRequest = null; m_asyncResponse = new AsyncWrapper(this, false); m_state = RequestStates.GetResponse; return (WebResponse)m_asyncResponse.GetResponseOrStream(); }
/// <summary> /// Gets the request stream /// </summary> /// <returns>The request stream</returns> public Stream GetRequestStream() { if (m_state == RequestStates.GetRequest) return (Stream)m_asyncRequest.GetResponseOrStream(); if (m_state != RequestStates.Created) throw new InvalidOperationException(); m_asyncRequest = new AsyncWrapper(this, true); m_state = RequestStates.GetRequest; return TrySetTimeout((Stream)m_asyncRequest.GetResponseOrStream(), m_activity_timeout); }
/// <summary> /// Gets the request stream /// </summary> /// <returns>The request stream</returns> public Stream GetRequestStream() { if (m_state == RequestStates.GetRequest) return (Stream)m_asyncRequest.GetResponseOrStream(); if (m_state != RequestStates.Created) throw new InvalidOperationException(); m_asyncRequest = new AsyncWrapper(this, true); m_state = RequestStates.GetRequest; var s = (Stream)m_asyncRequest.GetResponseOrStream(); try { s.WriteTimeout = m_activity_timeout; } catch { } return s; }