Пример #1
0
            private void SetContentLength(CURLoption lengthOption)
            {
                Debug.Assert(lengthOption == CURLoption.CURLOPT_POSTFIELDSIZE || lengthOption == CURLoption.CURLOPT_INFILESIZE);

                if (_requestMessage.Content == null)
                {
                    // Tell libcurl there's no data to be sent.
                    SetCurlOption(lengthOption, 0L);
                    return;
                }

                long?contentLengthOpt = _requestMessage.Content.Headers.ContentLength;

                if (contentLengthOpt != null)
                {
                    long contentLength = contentLengthOpt.GetValueOrDefault();
                    if (contentLength <= int.MaxValue)
                    {
                        // Tell libcurl how much data we expect to send.
                        SetCurlOption(lengthOption, contentLength);
                    }
                    else
                    {
                        // Similarly, tell libcurl how much data we expect to send.  However,
                        // as the amount is larger than a 32-bit value, switch to the "_LARGE"
                        // equivalent libcurl options.
                        SetCurlOption(
                            lengthOption == CURLoption.CURLOPT_INFILESIZE ? CURLoption.CURLOPT_INFILESIZE_LARGE : CURLoption.CURLOPT_POSTFIELDSIZE_LARGE,
                            contentLength);
                    }
                    return;
                }

                // There is content but we couldn't determine its size.  Don't set anything.
            }
Пример #2
0
 internal void SetCurlOption(CURLoption option, SafeHandle value)
 {
     ThrowIfCURLEError(Interop.Http.EasySetOptionPointer(_easyHandle, option, value));
 }
Пример #3
0
 internal void SetCurlOption(CURLoption option, long value)
 {
     ThrowIfCURLEError(Interop.Http.EasySetOptionLong(_easyHandle, option, value));
 }
Пример #4
0
 internal CURLcode TrySetCurlOption(CURLoption option, string value)
 {
     return(Interop.Http.EasySetOptionString(_easyHandle, option, value));
 }