Difference between revisions of "HttpRequest class"

From Catglobe Wiki
Jump to: navigation, search
m
Line 22: Line 22:
 
{{CGscriptProperties_Template|ReturnType=number|Name=<nowiki>Timeout</nowiki>|HasGetter=1|HasSetter=1|Description=<nowiki>Get/Set the timeout (in millisec)</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=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|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>
+
'''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:#a52a2a;">Examples</span>  ====
Line 33: Line 33:
 
WebResponse wr = hr.GetResponse();   
 
WebResponse wr = hr.GetResponse();   
 
responseString = wr.Response();
 
responseString = wr.Response();
print(responseString);</source></span>
+
print(responseString);</source></span>  
  
 
[[Category:Data_Types_Literals_and_Variables]]
 
[[Category:Data_Types_Literals_and_Variables]]
 +
__NOTOC__

Revision as of 11:45, 7 November 2011

HttpRequest



Object to make requests to sites

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
  • 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.
  • number Timeout { get; set; } - Get/Set the timeout (in millisec)
  • TypeInformation TypeInformation { get; } - Get information about this class.


More information about an HTTP Message: http://www.jmarshall.com/easy/http/

Examples

string uri = "http://google.com";
string responseString;
HttpRequest hr = new HttpRequest(uri);
WebResponse wr = hr.GetResponse();  
responseString = wr.Response();
print(responseString);