public EasyRequest(CurlHandler handler, HttpRequestMessage requestMessage, CancellationToken cancellationToken) :
                base(TaskCreationOptions.RunContinuationsAsynchronously)
            {
                // Store supplied arguments
                _handler           = handler;
                _requestMessage    = requestMessage;
                _responseMessage   = new CurlResponseMessage(requestMessage);
                _cancellationToken = cancellationToken;

                // Create the underlying easy handle
                _easyHandle = Interop.libcurl.curl_easy_init();
                if (_easyHandle.IsInvalid)
                {
                    throw new OutOfMemoryException();
                }

                // Configure the easy handle
                SetUrl();
                SetDebugging();
                SetMultithreading();
                SetRedirection();
                SetVerb();
                SetDecompressionOptions();
                SetProxyOptions();
                SetCredentialsOptions();
                SetCookieOption();
                SetRequestHeaders();
            }
Example #2
0
 public EasyRequest(CurlHandler handler, HttpRequestMessage requestMessage, CancellationToken cancellationToken) :
     base(TaskCreationOptions.RunContinuationsAsynchronously)
 {
     _handler           = handler;
     _requestMessage    = requestMessage;
     _cancellationToken = cancellationToken;
     _responseMessage   = new CurlResponseMessage(this);
 }
            public EasyRequest(CurlHandler handler, HttpRequestMessage requestMessage, CancellationToken cancellationToken) :
                base(TaskCreationOptions.RunContinuationsAsynchronously)
            {
                _handler           = handler;
                _requestMessage    = requestMessage;
                _cancellationToken = cancellationToken;

                if (requestMessage.Content != null)
                {
                    _requestContentStream = new HttpContentAsyncStream(requestMessage.Content);
                }

                _responseMessage = new CurlResponseMessage(this);
            }
Example #4
0
            public EasyRequest(CurlHandler handler, MultiAgent agent, HttpRequestMessage requestMessage, CancellationToken cancellationToken) :
                base(TaskCreationOptions.RunContinuationsAsynchronously)
            {
                Debug.Assert(handler != null, $"Expected non-null {nameof(handler)}");
                Debug.Assert(agent != null, $"Expected non-null {nameof(agent)}");
                Debug.Assert(requestMessage != null, $"Expected non-null {nameof(requestMessage)}");

                _handler = handler;
                _associatedMultiAgent = agent;
                _requestMessage       = requestMessage;

                _cancellationToken = cancellationToken;
                _responseMessage   = new CurlResponseMessage(this);
            }