|
|
|
|
- Header of HTTP request
- Managing the errors of Web server
- Operating mode of HTTPRequest/HTTPGetResult with a destination
- Retrieval
- Limits
HTTPGetResult (Function) In french: HTTPDonneRésultat Retrieves the result or the header of last HTTP request run. This request was initiated by HTTPRequest or by HTTPSendForm.
// Retrieve the elements of "www.windev.com" Web page ResStart = HTTPRequest("http://www.windev.com") IF ResStart = True THEN ResCode is string = HTTPGetResult() Info("HTML code: " + ResCode) ResHeader is string = HTTPGetResult(httpHeader) Info("Header: " + ResHeader) ResCookie is string = HTTPGetResult(httpCookie) Info("Cookie: " + ResCookie) END
// Example for processing an error returned by the Web server Url is string HTTP_Res is string HTTPError is string Url = "http://www.amazon.fr/s/ref=nb_ss?__mk_fr_FR=AMAZON&url" + ... "=search-alias=aps&field-keywords=2746049805" // Send the request to the Amazon server IF HTTPRequest(Url) THEN // The request was sent, it was a valid URL HTTP_Res = HTTPGetResult() IF Length(HTTP_Res) = 0 THEN // Error of the Web server, // the error details can be found in the page header HTTPError = HTTPGetResult(httpHeader) Error(HTTPError) END END
Syntax
<Result> = HTTPGetResult([<Type of information>])
<Result>: Buffer or character string - Result of last HTTP request if the httpResult constant is specified.
- Header of last HTTP request if the httpHeader constant is specified.
<Type of information>: Optional constant Type of information to retrieve: | | httpCookie | Block of cookies (extracted from the HTTP headers). | httpHeader | Header of last HTTP request. | httpResult (Default value) | Result of last HTTP request. Caution: In this case, in Unicode, <Result> is a Buffer. |
Remarks Header of HTTP request A header of HTTP request provides various information about the HTTP request (date, server used, etc.). When running the following HTTP request:
ResStart = HTTPRequest("http://www.windev.com")
The retrieved header is:
HTTP/1.1 200 OK<\r><\n> Date: Tue, 10 Jul 2001 13:19:08 GMT<\r><\n> Serveur: Apache/1.3.11 (Unix) PHP/4.0.1<\r><\n> Last-Modified: Thu, 04 Jan 2001 13:20:11 GMT<\r><\n> ETag: "4107f-5f7b-3a54788b"<\r><\n> Accept-Ranges: bytes<\r><\n> Content-Length: 24443<\r><\n> Connexion: close<\r><\n> Content-Type: image/gif<\r><\n><\r>
Managing the errors of Web server Some Web servers return an error in the http header. For example, the error can correspond to a notification for page move (url rewriting). If the content of the page returned by HTTPGetResult is empty, you must check the page header. Example of error header when moving a page (url rewriting):
HTTP/1.1 302 MovedTemporarily Date: Wed, 30 Sep 2009 15:38:48 GMT Serveur: Serveur x-amz-id-1: 1KR8DDF5DV380D14DHTC x-amz-id-2: pU0oo3rO/L+5kLNg4Yc4MPd0jF3qwyEI4nGaOhMgYkk= Location: http://www.amazon.fr/WinDev-14-fundamental-d%C3%A9veloppement -Pr%C3%A9sentation/dp/2746049805/ref=sr_11_1/277-8952281-8252733?ie= UTF8&qid=1254325128&sr=11-1 Vary: Accept-Encoding,User-Agent nnCoection: close Content-Type: text/html; charset=ISO-8859-15 Set-cookie: session-id-time=1254866400l; path=/; domain=.amazon.fr; expires=Tue Oct 06 22:00:00 2009 GMT Set-cookie: session-id=277-8952281-8252733; path=/; domain=.amazon.fr; expires=Tue Oct 06 22:00:00 2009 GMT Content-Length: 0
Retrieval HTTPGetResult can also be used to retrieve an image or a binary document (see the Example).
This page is also available for…
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|