SendPost() public static method

public static SendPost ( string url, Stream body, bool useCompression ) : Task
url string
body System.IO.Stream
useCompression bool
return Task
Esempio n. 1
0
 public static async Task <string> SendPost(string url, string query, bool useCompression)
 {
     using (var body = new MemoryStream(Encoding.Default.GetBytes(query)))
     {
         return(await WebHelper.SendPost(url, body, useCompression));
     }
 }
Esempio n. 2
0
        /// <summary>
        /// Submit audio data to the AcoustID webservice.
        /// </summary>
        /// <param name="requests">The submit request data.</param>
        /// <returns></returns>
        public async Task <SubmitResponse> SubmitAsync(IEnumerable <SubmitRequest> requests)
        {
            try
            {
                using (var body = BuildRequestBody(requests))
                {
                    // If the request contains invalid parameters, the server will return
                    // "400 Bad Request" and we'll end up in the first catch block.
                    string response = await WebHelper.SendPost(URL, body, UseCompression);

                    return(parser.ParseSubmitResponse(response));
                }
            }
            catch (WebException e)
            {
                // Handle bad requests gracefully.
                return(CreateErrorResponse(e.Response as HttpWebResponse));
            }
            catch (Exception e)
            {
                throw e;
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Lookup a fingerprint using the AcoustID webservice.
        /// </summary>
        /// <param name="fingerprint">The audio fingerprint.</param>
        /// <param name="duration">The total duration of the audio.</param>
        /// <param name="meta">Request meta information.</param>
        /// <returns>A task which returns a <see cref="LookupResponse"/>.</returns>
        public async Task <LookupResponse> GetAsync(string fingerprint, int duration, string[] meta)
        {
            try
            {
                using (var body = BuildRequestBody(fingerprint, duration, meta))
                {
                    // If the request contains invalid parameters, the server will return
                    // "400 Bad Request" and we'll end up in the first catch block.
                    string response = await WebHelper.SendPost(URL, body, UseCompression);

                    return(parser.ParseLookupResponse(response));
                }
            }
            catch (WebException e)
            {
                // Handle bad requests gracefully.
                return(CreateErrorResponse(e.Response as HttpWebResponse));
            }
            catch (Exception e)
            {
                throw e;
            }
        }