Exemplo n.º 1
0
        /// <summary>Attempts to get data from a web request.</summary>
        /// <param name="url">The URL for the request.</param>
        /// <param name="method">The OneAll supported HTTP method to use.</param>
        /// <param name="creds">The <see cref="Credential"/> used to authenticate the call, or null for calls not requiring authentication.</param>
        /// <param name="data">The raw data to be posted.</param>
        /// <param name="callBack">The call-back to invoke after the request is complete, if null this method is synchronous.</param>
        /// <param name="state">The state information, ignored if callBack is null.</param>
        internal static byte[] Post(Uri url, OneAllMethod method, Credential creds, byte[] data, BinaryReceivedHandler callBack, object state)
        {
            byte[] retVal = null;

            if (callBack == null) { retVal = PostSync(url, method, creds, data); }
            else { PostAsync(url, method, creds, data, callBack, state); }

            return retVal;
        }
Exemplo n.º 2
0
 /// <summary>Attempts to get data from a web request.</summary>
 /// <param name="request">The HTTP web request.</param>
 /// <param name="method">The OneAll supported HTTP method to use.</param>
 /// <param name="creds">The <see cref="Credential"/> used to authenticate the call, or null for calls not requiring authentication.</param>
 /// <param name="callBack">The call-back to invoke after the request is complete.</param>
 /// <param name="state">The initial state object provided.</param>
 private static void GetAsync(HttpWebRequest request, OneAllMethod method, Credential creds, BinaryReceivedHandler callBack, object state)
 {
     request.SetHTTPMethod(method);
     request.SetBasicAuth(creds);
     request.BeginGetResponse(OnRequestCompleted, new BinaryWebClientState()
     {
         Request = request,
         Callback = callBack,
         State = state
     });
 }
Exemplo n.º 3
0
        /// <summary>Attempts to get data from a web request.</summary>
        /// <param name="url">The URL for the request.</param>
        /// <param name="method">The OneAll supported HTTP method to use.</param>
        /// <param name="creds">The <see cref="Credential"/> used to authenticate the call, or null for calls not requiring authentication.</param>
        /// <param name="callBack">The call-back to invoke after the request is complete, if null this method is synchronous.</param>
        /// <param name="state">The state information, ignored if callBack is null.</param>
        internal static byte[] Get(Uri url, OneAllMethod method, Credential creds, BinaryReceivedHandler callBack, object state)
        {
            byte[] retVal = null;

            if (callBack == null)
            {
                retVal = GetSync(url, method, creds);
            }
            else
            {
                GetAsync(url, method, creds, callBack, state);
            }

            return(retVal);
        }
Exemplo n.º 4
0
 /// <summary>Attempts to get data from a web request.</summary>
 /// <param name="request">The HTTP web request.</param>
 /// <param name="method">The OneAll supported HTTP method to use.</param>
 /// <param name="creds">The <see cref="Credential"/> used to authenticate the call, or null for calls not requiring authentication.</param>
 /// <param name="callBack">The call-back to invoke after the request is complete.</param>
 /// <param name="state">The initial state object provided.</param>
 private static void GetAsync(HttpWebRequest request, OneAllMethod method, Credential creds, BinaryReceivedHandler callBack, object state)
 {
     request.SetHTTPMethod(method);
     request.SetBasicAuth(creds);
     request.BeginGetResponse(OnRequestCompleted, new BinaryWebClientState()
     {
         Request  = request,
         Callback = callBack,
         State    = state
     });
 }
Exemplo n.º 5
0
 /// <summary>Attempts to get data from a web request.</summary>
 /// <param name="url">The URL for the request.</param>
 /// <param name="method">The OneAll supported HTTP method to use.</param>
 /// <param name="creds">The <see cref="Credential"/> used to authenticate the call, or null for calls not requiring authentication.</param>
 /// <param name="callBack">The call-back to invoke after the request is complete.</param>
 /// <param name="state">The state information.</param>
 private static void GetAsync(Uri url, OneAllMethod method, Credential creds, BinaryReceivedHandler callBack, object state)
 {
     GetAsync(HttpWebRequest.Create(url) as HttpWebRequest, method, creds, callBack, state);
 }
Exemplo n.º 6
0
        /// <summary>Attempts to get data from a web request.</summary>
        /// <param name="request">The HTTP web request.</param>
        /// <param name="method">The OneAll supported HTTP method to use.</param>
        /// <param name="creds">The <see cref="Credential"/> used to authenticate the call, or null for calls not requiring authentication.</param>
        /// <param name="data">The raw data to be posted.</param>
        /// <param name="callBack">The call-back to invoke after the request is complete.</param>
        /// <param name="state">The initial state object provided.</param>
        private static void PostAsync(HttpWebRequest request, OneAllMethod method, Credential creds, byte[] data, BinaryReceivedHandler callBack, object state)
        {
            request.ContentType = OneAllConstants.HTTP_CONTENTTYPE_FORMURLENCODE;
            request.SetHTTPMethod(method);
            request.SetBasicAuth(creds);

            request.BeginGetRequestStream(OnRequestStreamObtained, new BinaryWebClientState()
            {
                Request  = request,
                Callback = callBack,
                State    = state,
                Data     = data
            });
        }
Exemplo n.º 7
0
 /// <summary>Attempts to get data from a web request.</summary>
 /// <param name="url">The URL for the request.</param>
 /// <param name="method">The OneAll supported HTTP method to use.</param>
 /// <param name="creds">The <see cref="Credential"/> used to authenticate the call, or null for calls not requiring authentication.</param>
 /// <param name="callBack">The call-back to invoke after the request is complete.</param>
 /// <param name="state">The state information.</param>
 private static void GetAsync(Uri url, OneAllMethod method, Credential creds, BinaryReceivedHandler callBack, object state)
 {
     GetAsync(HttpWebRequest.Create(url) as HttpWebRequest, method, creds, callBack, state);
 }
Exemplo n.º 8
0
        /// <summary>Attempts to get data from a web request.</summary>
        /// <param name="request">The HTTP web request.</param>
        /// <param name="method">The OneAll supported HTTP method to use.</param>
        /// <param name="creds">The <see cref="Credential"/> used to authenticate the call, or null for calls not requiring authentication.</param>
        /// <param name="data">The raw data to be posted.</param>
        /// <param name="callBack">The call-back to invoke after the request is complete.</param>
        /// <param name="state">The initial state object provided.</param>
        private static void PostAsync(HttpWebRequest request, OneAllMethod method, Credential creds, byte[] data, BinaryReceivedHandler callBack, object state)
        {
            request.ContentType = OneAllConstants.HTTP_CONTENTTYPE_FORMURLENCODE;
            request.SetHTTPMethod(method);
            request.SetBasicAuth(creds);

            request.BeginGetRequestStream(OnRequestStreamObtained, new BinaryWebClientState()
            {
                Request = request,
                Callback = callBack,
                State = state,
                Data = data
            });
        }