Ejemplo n.º 1
0
 /// <summary>
 /// Post a single MIME encoded payload to a URI
 /// </summary>
 /// <param name="uri">The URI of the web service to receive the Http post message</param>
 /// <param name="retries">Number of times to retry post if there is an error</param>
 /// <param name="mimePart">MIME encoded payload</param>
 /// <param name="callback">Method called on failure or success that is passed an AsyncResult whose Result property is set to HttpResult</param>
 /// <returns>WebRequest IAsyncResult object</returns>
 public IAsyncResult Post(Uri uri, int retries, MimePart mimePart, AsyncCallback callback)
 {
     return(Post(uri, retries, new List <MimePart> {
         mimePart
     }, callback));
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Post a single MIME encoded payload to a URI
 /// </summary>
 /// <param name="uri">The URI of the web service to receive the Http post message</param>
 /// <param name="retries">Number of times to retry post if there is an error</param>
 /// <param name="mimePart">MIME encoded payload</param>
 /// <param name="callback">Method called on failure or success that is passed an AsyncResult whose Result property is set to HttpResult</param>
 /// <returns>WebRequest IAsyncResult object</returns>
 public IAsyncResult Post(Uri uri, int retries, MimePart mimePart, AsyncCallback callback)
 {
     return Post(uri, retries, new List<MimePart> { mimePart }, callback);
 }
Ejemplo n.º 3
0
        private static void CreateSinglePartRequest(WebRequest request, IAsyncResult asyncResult, MimePart part)
        {
            // End the operation
            using (Stream postStream = request.EndGetRequestStream(asyncResult))
            {
                if (!part.IsFile)
                {
                    request.ContentType = string.Format("{0}; charset=UTF-8", part.ContentType);

                    // Write text value into the HTTP request
                    byte[] byteArray = Encoding.UTF8.GetBytes(part.Value);
                    postStream.Write(byteArray, 0, byteArray.Length);
                }
                else
                {
                    request.ContentType = part.ContentType;
                    // Copy binary data to HTTP request
                    part.Stream.CopyTo(postStream);
                }
            }
        }
Ejemplo n.º 4
0
        private static void CreateSinglePartRequest(WebRequest request, IAsyncResult asyncResult, MimePart part)
        {
            // End the operation
            using (Stream postStream = request.EndGetRequestStream(asyncResult))
            {
                if (!part.IsFile)
                {
                    request.ContentType = string.Format("{0}; charset=UTF-8", part.ContentType);

                    // Write text value into the HTTP request
                    byte[] byteArray = Encoding.UTF8.GetBytes(part.Value);
                    postStream.Write(byteArray, 0, byteArray.Length);
                }
                else
                {
                    request.ContentType = part.ContentType;
                    // Copy binary data to HTTP request
                    part.Stream.CopyTo(postStream);
                }
            }
        }