Difference between revisions of "HttpRequest class"

From Catglobe Wiki
Jump to: navigation, search
 
(One intermediate revision by one other user not shown)
Line 2: Line 2:
 
|Name=<nowiki>HttpRequest</nowiki>
 
|Name=<nowiki>HttpRequest</nowiki>
 
|Description=<nowiki>Object to make requests to sites</nowiki>
 
|Description=<nowiki>Object to make requests to sites</nowiki>
|Constructors=
+
|InheritsFrom=object|Constructors=
 
{{CGscriptConstructors_Template|Parameters=
 
{{CGscriptConstructors_Template|Parameters=
 
{{CGscriptParameters_Template|Type=string|Name=<nowiki>uri</nowiki>|Description=<nowiki>The uri to visit.</nowiki>}}
 
{{CGscriptParameters_Template|Type=string|Name=<nowiki>uri</nowiki>|Description=<nowiki>The uri to visit.</nowiki>}}
Line 14: Line 14:
 
{{CGscriptParameters_Template|Type=string|Name=<nowiki>body</nowiki>|Description=<nowiki>A body to include in the request - Always UTF-8 encoded</nowiki>}}
 
{{CGscriptParameters_Template|Type=string|Name=<nowiki>body</nowiki>|Description=<nowiki>A body to include in the request - Always UTF-8 encoded</nowiki>}}
 
|Description=<nowiki>Actually do the request, and get the response back</nowiki>}}
 
|Description=<nowiki>Actually do the request, and get the response back</nowiki>}}
{{CGscriptMethods_Template|ReturnType=string|Name=<nowiki>ToString</nowiki>|Description=<nowiki>The string representation of the object.</nowiki>}}
+
{{CGscriptMethods_Template|ReturnType=Empty|Name=<nowiki>SetIgnoreCertificatesErrors</nowiki>|Description=<nowiki>Ignore any ssl/tls errors due to certificate validation</nowiki>}}
 +
{{CGscriptMethods_Template|ReturnType=string|Name=<nowiki>ToString</nowiki>|Inherited=object|Description=<nowiki>The string representation of the object.</nowiki>}}
 
|Properties=
 
|Properties=
 
{{CGscriptProperties_Template|ReturnType=string|Name=<nowiki>ContentType</nowiki>|HasGetter=1|HasSetter=1|Description=<nowiki>Get/Set the ContentType</nowiki>}}
 
{{CGscriptProperties_Template|ReturnType=string|Name=<nowiki>ContentType</nowiki>|HasGetter=1|HasSetter=1|Description=<nowiki>Get/Set the ContentType</nowiki>}}
Line 20: Line 21:
 
{{CGscriptProperties_Template|ReturnType=string|Name=<nowiki>Method</nowiki>|HasGetter=1|HasSetter=1|Description=<nowiki>Choose which HTTP method to request with</nowiki>}}
 
{{CGscriptProperties_Template|ReturnType=string|Name=<nowiki>Method</nowiki>|HasGetter=1|HasSetter=1|Description=<nowiki>Choose which HTTP method to request with</nowiki>}}
 
{{CGscriptProperties_Template|ReturnType=string|Name=<nowiki>ObjectTypeName</nowiki>|HasGetter=1|Description=<nowiki>The name of the type of object.</nowiki>}}
 
{{CGscriptProperties_Template|ReturnType=string|Name=<nowiki>ObjectTypeName</nowiki>|HasGetter=1|Description=<nowiki>The name of the type of object.</nowiki>}}
{{CGscriptProperties_Template|ReturnType=number|Name=<nowiki>Timeout</nowiki>|HasGetter=1|HasSetter=1|Description=<nowiki>Get/Set the timeout (in millisec)</nowiki>}}
+
{{CGscriptProperties_Template|ReturnType=int|Name=<nowiki>Timeout</nowiki>|HasGetter=1|HasSetter=1|Description=<nowiki>Get/Set the timeout (in millisec)</nowiki>}}
{{CGscriptProperties_Template|ReturnType=TypeInformation|Name=<nowiki>TypeInformation</nowiki>|HasGetter=1|Description=<nowiki>Get information about this class.</nowiki>}}
+
{{CGscriptProperties_Template|ReturnType=TypeInformation|Name=<nowiki>TypeInformation</nowiki>|HasGetter=1|Inherited=object|Description=<nowiki>Get information about this class.</nowiki>}}
}}  
+
}}
 
 
'''More information about an HTTP Message:''' [http://www.jmarshall.com/easy/http/ http://www.jmarshall.com/easy/http/]<br>
 
 
 
==== <span style="color:#a52a2a;">Examples</span>  ====
 
 
 
<span style="color: rgb(165, 42, 42);"><source lang="javascript">string uri = "http://google.com";
 
string responseString;
 
HttpRequest hr = new HttpRequest(uri);
 
WebResponse wr = hr.GetResponse(); 
 
responseString = wr.Response();
 
print(responseString);</source></span>
 

Latest revision as of 06:52, 2 July 2020

HttpRequest



Object to make requests to sites

Parent class

Inherits from object

Constructors

  • (string uri "The uri to visit.") - Visit a uri
  • (string uri "The uri to visit.", WebResponse takeCookiesFrom "If you made a previous request and want to transfer the cookies from that response, give the response object here.") - Visit a uri with cookies

Methods

  • WebResponse GetResponse() - Actually do the request, and get the response back
  • WebResponse GetResponse(string body "A body to include in the request - Always UTF-8 encoded") - Actually do the request, and get the response back
  • Empty SetIgnoreCertificatesErrors() - Ignore any ssl/tls errors due to certificate validation
  • (From object) string ToString() - The string representation of the object.

Properties

  • string ContentType { get; set; } - Get/Set the ContentType
  • Dictionary Headers { set; } - Apply headers to the request
  • string Method { get; set; } - Choose which HTTP method to request with
  • string ObjectTypeName { get; } - The name of the type of object.
  • int Timeout { get; set; } - Get/Set the timeout (in millisec)
  • (From object) TypeInformation TypeInformation { get; } - Get information about this class.