コード例 #1
0
        public override string ToString()
        {
            StringBuilder sb = new StringBuilder();

            sb.Append("StatusCode: ");
            sb.Append((int)_statusCode);

            sb.Append(", ReasonPhrase: '");
            sb.Append(ReasonPhrase ?? "<null>");

            sb.Append("', Version: ");
            sb.Append(_version);

            sb.Append(", Content: ");
            sb.Append(_content == null ? "<null>" : _content.GetType().ToString());

            sb.AppendLine(", Headers:");
            HeaderUtilities.DumpHeaders(sb, _headers, _content?.Headers);

            if (_trailingHeaders != null)
            {
                sb.AppendLine(", Trailing Headers:");
                HeaderUtilities.DumpHeaders(sb, _trailingHeaders);
            }

            return(sb.ToString());
        }
コード例 #2
0
        public override string ToString()
        {
            StringBuilder sb = new StringBuilder();

            sb.Append("Method: ");
            sb.Append(method);

            sb.Append(", RequestUri: '");
            sb.Append(requestUri == null ? "<null>" : requestUri.ToString());

            sb.Append("', Version: ");
            sb.Append(version);

            sb.Append(", Content: ");
            sb.Append(content == null ? "<null>" : content.GetType().FullName);

            sb.Append(", Headers:\r\n");
            sb.Append(HeaderUtilities.DumpHeaders(headers, content == null ? null : content.Headers));

            return(sb.ToString());
        }
コード例 #3
0
        public override string ToString()
        {
            StringBuilder sb = new StringBuilder();

            sb.Append("StatusCode: ");
            sb.Append((int)_statusCode);

            sb.Append(", ReasonPhrase: '");
            sb.Append(ReasonPhrase ?? "<null>");

            sb.Append("', Version: ");
            sb.Append(_version);

            sb.Append(", Content: ");
            sb.Append(_content == null ? "<null>" : _content.GetType().ToString());

            sb.Append(", Headers:\r\n");
            sb.Append(HeaderUtilities.DumpHeaders(_headers, _content == null ? null : _content.Headers));

            return(sb.ToString());
        }
コード例 #4
0
ファイル: HttpRequestMessage.cs プロジェクト: pgovind/runtime
        public override string ToString()
        {
            StringBuilder sb = new StringBuilder();

            sb.Append("Method: ");
            sb.Append(_method);

            sb.Append(", RequestUri: '");
            sb.Append(_requestUri == null ? "<null>" : _requestUri.ToString());

            sb.Append("', Version: ");
            sb.Append(_version);

            sb.Append(", Content: ");
            sb.Append(_content == null ? "<null>" : _content.GetType().ToString());

            sb.AppendLine(", Headers:");
            HeaderUtilities.DumpHeaders(sb, _headers, _content?.Headers);

            return(sb.ToString());
        }
コード例 #5
0
        public override string ToString()
        {
            StringBuilder sb = new StringBuilder();

            sb.Append("StatusCode: ");
            sb.Append((int)statusCode);

            sb.Append(", ReasonPhrase: '");
            sb.Append(reasonPhrase == null ? "<null>" : reasonPhrase);

            sb.Append("', Version: ");
            sb.Append(version);

            sb.Append(", Content: ");
            sb.Append(content == null ? "<null>" : content.GetType().FullName);

            sb.Append(", Headers:\r\n");
            sb.Append(HeaderUtilities.DumpHeaders(headers, content == null ? null : content.Headers));

            return(sb.ToString());
        }
コード例 #6
0
ファイル: CurlHandler.cs プロジェクト: nuskarthik/corefx
        private SafeCurlSlistHandle SetRequestHeaders(SafeCurlHandle handle, HttpRequestMessage request)
        {
            SafeCurlSlistHandle retVal = new SafeCurlSlistHandle();

            if (request.Headers == null)
            {
                return(retVal);
            }

            HttpHeaders contentHeaders = null;

            if (request.Content != null)
            {
                SetChunkedModeForSend(request);

                // TODO: Content-Length header isn't getting correctly placed using ToString()
                // This is a bug in HttpContentHeaders that needs to be fixed.
                if (request.Content.Headers.ContentLength.HasValue)
                {
                    long contentLength = request.Content.Headers.ContentLength.Value;
                    request.Content.Headers.ContentLength = null;
                    request.Content.Headers.ContentLength = contentLength;
                }
                contentHeaders = request.Content.Headers;
            }

            string[] allHeaders = HeaderUtilities.DumpHeaders(request.Headers, contentHeaders)
                                  .Split(s_headerDelimiters, StringSplitOptions.RemoveEmptyEntries);
            bool gotReference = false;

            try
            {
                retVal.DangerousAddRef(ref gotReference);
                IntPtr rawHandle = IntPtr.Zero;
                for (int i = 0; i < allHeaders.Length; i++)
                {
                    string header = allHeaders[i].Trim();
                    if (header.Equals("{") || header.Equals("}"))
                    {
                        continue;
                    }
                    rawHandle = Interop.libcurl.curl_slist_append(rawHandle, header);
                    retVal.SetHandle(rawHandle);
                }

                // Since libcurl always adds a Transfer-Encoding header, we need to explicitly block
                // it if caller specifically does not want to set the header
                if (request.Headers.TransferEncodingChunked.HasValue && !request.Headers.TransferEncodingChunked.Value)
                {
                    rawHandle = Interop.libcurl.curl_slist_append(rawHandle, NoTransferEncoding);
                    retVal.SetHandle(rawHandle);
                }

                if (!retVal.IsInvalid)
                {
                    SetCurlOption(handle, CURLoption.CURLOPT_HTTPHEADER, rawHandle);
                }
            }
            finally
            {
                if (gotReference)
                {
                    retVal.DangerousRelease();
                }
            }

            return(retVal);
        }