Exemplo n.º 1
0
 /// <summary>
 /// Perform GET and return response from URL.
 /// </summary>
 /// <param name="url"></param>
 /// <param name="acceptType"></param>
 /// <returns></returns>
 public static Energy.Base.Http.Response Get(string url, string acceptType)
 {
     Energy.Base.Http.Request request = new Energy.Base.Http.Request()
     {
         Method     = "GET",
         Url        = url,
         AcceptType = acceptType,
     };
     Energy.Base.Http.Response response = Execute(request);
     return(response);
 }
Exemplo n.º 2
0
        private static void TestPutExe()
        {
            byte[] data = System.IO.File.ReadAllBytes(@"C:\DATA\example.exe");
            string url  = "http://localhost:6000/api/storage/xyz/path/to/file.data";
            string json;

            Energy.Base.Http.Response response = Energy.Core.Web.Post(url, data);
            json = response.Body;
            int responseCode = response.StatusCode;

            Console.WriteLine(responseCode);
            Console.WriteLine(json);
            Console.ReadLine();
        }
Exemplo n.º 3
0
 /// <summary>
 /// Perform PUT and return response from URL.
 /// </summary>
 /// <param name="url"></param>
 /// <param name="body"></param>
 /// <param name="contentType"></param>
 /// <param name="headers"></param>
 /// <returns></returns>
 public static Energy.Base.Http.Response Put(string url, object body, string contentType, string[] headers)
 {
     Energy.Base.Http.Request request = new Energy.Base.Http.Request()
     {
         Method      = "PUT",
         Url         = url,
         ContentType = contentType,
     };
     request.SetValue(body);
     if (headers != null && headers.Length > 0)
     {
         request.Headers.AddRange(headers);
     }
     Energy.Base.Http.Response response = Execute(request);
     return(response);
 }
Exemplo n.º 4
0
 /// <summary>
 /// Perform HEAD and return response from URL.
 /// </summary>
 /// <param name="url"></param>
 /// <param name="responseHeaders"></param>
 /// <returns></returns>
 public static Energy.Base.Http.Response Head(string url, out string[] responseHeaders)
 {
     Energy.Base.Http.Request request = new Base.Http.Request()
     {
         Method = "HEAD",
         Url    = url,
     };
     Energy.Base.Http.Response response = Execute(request);
     if (response == null)
     {
         responseHeaders = null;
         return(null);
     }
     else
     {
         responseHeaders = response.Headers.ToArray();
         return(response);
     }
 }