Inheritance: IDisposable
Esempio n. 1
0
            static void CreateAndPrepareWebRequest(HttpTransportAsyncResult self)
            {
                Trace(self, "CreateAndPrepareRequest");
                var request  = self.request;
                var settings = self.settings;
                var http     = (HttpWebRequest)WebRequest.Create(request.Uri);

                http.Method = request.Method;

                CopySettingsToHttpWebRequest(settings, http);
                HttpWebRequestTransportSettings messageSettings = request.GetPropertyOrDefault <HttpWebRequestTransportSettings>();

                if (messageSettings != null)
                {
                    CopySettingsToHttpWebRequest(messageSettings, http);
                }

                var calc = HttpMessageCore.CalculateEffectiveContentType(request);

                if (calc != request.Headers.ContentType)
                {
                    request.Headers.ContentType = calc;
                }

                if (!HttpContent.IsNullOrEmpty(request.Content) && request.Content.HasLength())
                {
                    if (request.Headers.ContentLength == null)
                    {
                        request.Headers.ContentLength = request.Content.GetLength();
                    }
                }

                CopyHeadersToHttpWebRequest(request.Headers, http);

                if (http.Method == "GET" && http.ContentLength >= 0)
                {
                    throw new NotSupportedException("can't set Content-Length to " + http.ContentLength + " on " + http.Method);
                }

                if (http.Method == "GET" && !HttpContent.IsNullOrEmpty(request.Content))
                {
                    throw new NotSupportedException("can't set a non-IsEmpty content on a GET: " + self.request.Content);
                }

                self.webRequest = http;
            }
Esempio n. 2
0
 public HttpRequestMessage(string method, Uri uri)
 {
     this.core   = new HttpMessageCore(this);
     this.Method = method;
     this.Uri    = uri;
 }
Esempio n. 3
0
 public HttpRequestMessage()
 {
     this.core   = new HttpMessageCore(this);
     this.Method = "GET";
 }
 public HttpResponseMessage()
 {
     this.core = new HttpMessageCore(this);
 }
Esempio n. 5
0
 public HttpRequestMessage(string method, Uri uri)
 {
     this.core = new HttpMessageCore(this);
     this.Method = method;
     this.Uri = uri;
 }
Esempio n. 6
0
 public HttpRequestMessage()
 {
     this.core = new HttpMessageCore(this);
     this.Method = "GET";
 }
 public HttpResponseMessage()
 {
     this.core = new HttpMessageCore(this);
 }