Toggle menu
876
3.8K
30.2K
279.1K
Catglobe Wiki
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

HttpRequest class: Difference between revisions

From Catglobe Wiki
Tungocman (talk | contribs)
No edit summary
No edit summary
 
(8 intermediate revisions by 4 users not shown)
Line 1: Line 1:
=== '''HttpRequest : Object to make requests to sites'''  ===
{{CGscriptClass_Template
 
|Name=<nowiki>HttpRequest</nowiki>
==== <span style="color:#a52a2a;">Constructors</span> ====
|Description=<nowiki>Object to make requests to sites</nowiki>
 
|InheritsFrom=object|Constructors=
'''(string uri '''''(The uri to visit.)''''')''' - Visit a uri<br>'''(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<br>  
{{CGscriptConstructors_Template|Parameters=
 
{{CGscriptParameters_Template|Type=string|Name=<nowiki>uri</nowiki>|Description=<nowiki>The uri to visit.</nowiki>}}
==== <span style="color:#a52a2a;">Methods</span> ====
|Description=<nowiki>Visit a uri</nowiki>}}
 
{{CGscriptConstructors_Template|Parameters=
'''WebResponse GetResponse()''' - Actually do the request, and get the response back<br>'''WebResponse GetResponse(string body '''''(A body to include in the request - Always UTF-8 encoded)''''')''' - Actually do the request, and get the response back<br>'''string ToString()''' - The string representation of the object.<br>  
{{CGscriptParameters_Template|Type=string|Name=<nowiki>uri</nowiki>|Description=<nowiki>The uri to visit.</nowiki>|Comma=,}}{{CGscriptParameters_Template|Type=WebResponse|Name=<nowiki>takeCookiesFrom</nowiki>|Description=<nowiki>If you made a previous request and want to transfer the cookies from that response, give the response object here.</nowiki>}}
 
|Description=<nowiki>Visit a uri with cookies</nowiki>}}
==== <span style="color:#a52a2a;">Properties</span> ====
|Methods=
 
{{CGscriptMethods_Template|ReturnType=WebResponse|Name=<nowiki>GetResponse</nowiki>|Description=<nowiki>Actually do the request, and get the response back</nowiki>}}
'''string ContentType HasGetter HasSetter''' - Get/Set the ContentType<br>'''Dictionary Headers HasSetter''' - Apply headers to the request<br>'''string Method HasGetter HasSetter''' - Choose which HTTP method to request with<br>'''string ObjectTypeName HasGetter''' - The name of the type of object.<br>'''number Timeout HasGetter HasSetter''' - Get/Set the timeout (in millisec)<br>'''TypeInformation TypeInformation HasGetter''' - Get information about this class.<br>  
{{CGscriptMethods_Template|ReturnType=WebResponse|Name=<nowiki>GetResponse</nowiki>|Parameters=
 
{{CGscriptParameters_Template|Type=string|Name=<nowiki>body</nowiki>|Description=<nowiki>A body to include in the request - Always UTF-8 encoded</nowiki>}}
==== <span style="color:#a52a2a;">Examples</span> ====
|Description=<nowiki>Actually do the request, and get the response back</nowiki>}}
 
{{CGscriptMethods_Template|ReturnType=Empty|Name=<nowiki>SetIgnoreCertificatesErrors</nowiki>|Description=<nowiki>Ignore any ssl/tls errors due to certificate validation</nowiki>}}
<span style="color: rgb(165, 42, 42);"><source lang="javascript">string uri = "http://google.com";
{{CGscriptMethods_Template|ReturnType=string|Name=<nowiki>ToString</nowiki>|Inherited=object|Description=<nowiki>The string representation of the object.</nowiki>}}
string responseString;
|Properties=
HttpRequest hr = new HttpRequest(uri);
{{CGscriptProperties_Template|ReturnType=string|Name=<nowiki>ContentType</nowiki>|HasGetter=1|HasSetter=1|Description=<nowiki>Get/Set the ContentType</nowiki>}}
WebResponse wr = hr.GetResponse(); 
{{CGscriptProperties_Template|ReturnType=Dictionary|Name=<nowiki>Headers</nowiki>|HasSetter=1|Description=<nowiki>Apply headers to the request</nowiki>}}
responseString = wr.Response();
{{CGscriptProperties_Template|ReturnType=string|Name=<nowiki>Method</nowiki>|HasGetter=1|HasSetter=1|Description=<nowiki>Choose which HTTP method to request with</nowiki>}}
print(responseString);</source></span>
{{CGscriptProperties_Template|ReturnType=string|Name=<nowiki>ObjectTypeName</nowiki>|HasGetter=1|Description=<nowiki>The name of the type of object.</nowiki>}}
 
{{CGscriptProperties_Template|ReturnType=int|Name=<nowiki>Timeout</nowiki>|HasGetter=1|HasSetter=1|Description=<nowiki>Get/Set the timeout (in millisec)</nowiki>}}
[[Category:Data_Types_Literals_and_Variables]]
{{CGscriptProperties_Template|ReturnType=TypeInformation|Name=<nowiki>TypeInformation</nowiki>|HasGetter=1|Inherited=object|Description=<nowiki>Get information about this class.</nowiki>}}
}}

Latest revision as of 04: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.