Пример #1
0
 /// <summary>
 /// Initializes all the values
 /// </summary>
 public virtual void Initialize()
 {
     this.RelativeURL   = string.Empty;
     this.ServerURL     = string.Empty;
     this.RequestBody   = string.Empty;
     this.URLParameters = new Dictionary <string, object>();
     this.RequestType   = Enums.SupportedHttpMethod.Get;
 }
Пример #2
0
        /// <summary>
        /// Send a request with byte array data
        /// </summary>
        /// <param name="relativeUrl">The relative url, eg., "/login". DO NOT use a full URL.</param>
        /// <param name="requestType">GET/POST/PUT/DELETE</param>
        /// <param name="data">JSON string or Url-based string</param>
        /// <param name="headers">Headers of the request sent to the server</param>
        /// <param name="showLog">Whether all information of Request/Response will be written to log. </param>
        /// <returns>HttpWebResponse of the request sent to the server. Check null before verifying the response.</returns>
        public HttpWebResponse SendRequest(string relativeUrl, Enums.SupportedHttpMethod requestType,
                                           byte[] data, Dictionary <string, string> headers, bool showLog = true)
        {
            CloseLatestResponse();
            string          url            = ServerURL + relativeUrl;
            DateTime        beforeTime     = System.DateTime.Now;
            HttpWebResponse returnResponse = this.SendRequestRecursive(url, requestType.ToString().ToUpper(), headers, data, showLog).Result;

            DateTime afterTime       = System.DateTime.Now;
            TimeSpan elapsedTime     = afterTime - beforeTime;
            string   processing_time = elapsedTime.ToString();

            return(returnResponse);
        }
Пример #3
0
 /// <summary>
 /// Sends Request Setting JSON as the Content-Type
 /// </summary>
 /// <param name="url">The Relative URL to API</param>
 /// <param name="method">The request Method Type (Post,Put or Delete)</param>
 /// <param name="requestBody">The request body content (JSON formatted string)</param>
 /// <param name="headers">The request headers used in the request to API</param>
 /// <returns>IHandler that contains the server response and HttpCode</returns>
 public HttpWebResponse SendAPIRequest(string url, Enums.SupportedHttpMethod method, string requestBody,
                                       Dictionary <string, string> headers)
 {
     return(SendRequest(url, method, requestBody, headers));
 }
Пример #4
0
 /// <summary>
 /// Send Delete Request
 /// </summary>
 /// <param name="url">The Relative URL to API</param>
 /// <param name="urlParameters">The URL parameters</param>
 /// <param name="requestBody">The request body content (JSON formatted string)</param>
 /// <param name="headers">The request headers used in the request to API</param>
 /// <param name="requestType">This parameter defines the Method type DELETE or POST for Special Requests</param>
 /// <returns>IHandler that contains the server response and HttpCode</returns>
 protected HttpWebResponse Delete(string url, Dictionary <string, string> urlParameters, string requestBody,
                                  Dictionary <string, string> headers, Enums.SupportedHttpMethod requestType = Enums.SupportedHttpMethod.Delete)
 {
     return(this.SendAPIRequest(url, requestType, requestBody, headers));
 }