Exemplo n.º 1
0
        /// <summary>
        /// Starts an asynchronous DAV-HTTP-Request.
        /// </summary>
        /// <param name="header">The DAV-Request header to used.</param>
        /// <param name="body">The DAV-Request-body to used.</param>
        /// <param name="userObject">User defined object to deliver to respose method.</param>
        /// <param name="response">A handler to call after the event completes.</param>
        public void StartRequest(DAVRequestHeader header, DAVRequestBody body, object userObject, Action <DAVRequestResult, object> response)
        {
            LastException = null;
            _relativeHost = new Uri(_host + header.RequestedResource);

            header.Headers[Header.Host] = _host.DnsSafeHost;
            // this is needed to modify some headers
            HttpWebRequest.RegisterPrefix("http", System.Net.Browser.WebRequestCreator.ClientHttp);
            HttpWebRequest.RegisterPrefix("https", System.Net.Browser.WebRequestCreator.ClientHttp);
            HttpWebRequest request = HttpWebRequest.CreateHttp(_host + header.RequestedResource);

            request.AllowReadStreamBuffering = false;
            request.Method = header.RequestedMethod.ToString();
            foreach (KeyValuePair <string, string> current in header.Headers)
            {
                // API restriction
                switch (current.Key)
                {
                case "Accept":
                    request.Accept = current.Value;
                    break;

                case "Content-Type":
                    request.ContentType = current.Value;
                    break;

                default:
                    request.Headers[current.Key] = current.Value;
                    break;
                }
            }
            if (_credit != null)
            {
                request.Credentials = _credit;
            }

            if (body != null)
            {
                request.BeginGetRequestStream(_EndRequestStream, new RequestStruct
                {
                    Callback   = response,
                    Request    = request,
                    UserObject = userObject,
                    Body       = body
                });
            }
            else
            {
                request.BeginGetResponse(_EndRequest, new RequestStruct
                {
                    Callback   = response,
                    Request    = request,
                    UserObject = userObject
                });
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Starts an asynchronous DAV-HTTP-Request.
        /// </summary>
        /// <param name="header">The DAV-Request header to used.</param>
        /// <param name="body">The DAV-Request-body to used.</param>
        /// <param name="userObject">User defined object to deliver to respose method.</param>
        /// <param name="response">A handler to call after the event completes.</param>
        public void StartRequest(DAVRequestHeader header, DAVRequestBody body, object userObject, Action<DAVRequestResult, object> response)
        {
            LastException = null;
            _relativeHost = new Uri(_host + header.RequestedResource);

            header.Headers[Header.Host] = _host.DnsSafeHost;
            // this is needed to modify some headers
            HttpWebRequest.RegisterPrefix("http", System.Net.Browser.WebRequestCreator.ClientHttp);
            HttpWebRequest.RegisterPrefix("https", System.Net.Browser.WebRequestCreator.ClientHttp);
            HttpWebRequest request = HttpWebRequest.CreateHttp(_host + header.RequestedResource);
            request.AllowReadStreamBuffering = false;
            request.Method = header.RequestedMethod.ToString();
            foreach (KeyValuePair<string, string> current in header.Headers)
            {
                // API restriction
                switch(current.Key) {
                    case "Accept":
                        request.Accept = current.Value;
                        break;
                    case "Content-Type":
                        request.ContentType = current.Value;
                        break;
                    default:
                        request.Headers[current.Key] = current.Value;
                        break;
                }
            }
            if (_credit != null)
            {
                request.Credentials = _credit;
            }

            if (body != null)
            {
                request.BeginGetRequestStream(_EndRequestStream, new RequestStruct
                {
                    Callback = response,
                    Request = request,
                    UserObject = userObject,
                    Body = body
                });
            }
            else
            {
                request.BeginGetResponse(_EndRequest, new RequestStruct
                {
                    Callback = response,
                    Request = request,
                    UserObject = userObject
                });
            }
        }
Exemplo n.º 3
0
 /// <summary>
 /// Starts an asynchronous DAV-HTTP-Request.
 /// </summary>
 /// <param name="header">The DAV-Request header to used.</param>
 /// <param name="userObject">User defined object to deliver to respose method.</param>
 /// <param name="response">A handler to call after the event completes.</param>
 public void StartRequest(DAVRequestHeader header, object userObject, Action <DAVRequestResult, object> response)
 {
     StartRequest(header, null, userObject, response);
 }
Exemplo n.º 4
0
 /// <summary>
 /// Starts an asynchronous DAV-HTTP-Request.
 /// </summary>
 /// <param name="header">The DAV-Request header to used.</param>
 /// <param name="userObject">User defined object to deliver to respose method.</param>
 /// <param name="response">A handler to call after the event completes.</param>
 public void StartRequest(DAVRequestHeader header, object userObject, Action<DAVRequestResult, object> response)
 {
     StartRequest(header, null, userObject, response);
 }