HTTP_POST()

Syntax

Result as P = HTTP_POST( URL as C [, Body as C [, Cookie as C [, Port as N [, Timeout as N, [ Show_Before_Send as L [, Validate_SSL_Certificate as L ]]]]]] )

Argument

Description

Result

A dot variable containing the server's response.

Argument

Type

Description

.error_text

C

The error message, if any.

.error_code

N

The error number, if any.

.headers

C

Response headers.

.body

C

Response body.

URL

The address of the server that will receive your data.

Body

The parameters you wish to send. The size of this field is unlimited.

Cookie

Optional. Default = "". Cookie data.

Port

Optional. Default = 80. The port to use.

Timeout

Optional. Default = 8000 milliseconds. The number of milliseconds to wait before timing out.

Show_Before_Send

Optional. Default = .F.. When .T., displays the request before being sent. Useful for debugging.

Validate_SSL_Certificate

Optional. Default = .T.. If the specified URL starts with "https://", this flag controls whether or not the certificate offered by the server will be validated. If set to .T., the request will always fail. If set to .F., the request may succeed, but the server's identity is not guaranteed.

Description

The HTTP_POST() function downloads from URL using HTTP/1.1 POST. The function returns a pointer with the parsed response from the server.

Note : When the server responds with a 302 code, HTTP_POST() does not automatically use the new URL. The developer needs to examine result.parsed_headers.status_code, then if appropriate, try the URL provided in   result.parsed_headers.location. Refer to HTTP_GET()for an example.

The parsed response will include several element, including the following.

Argument

Example

Result.parsed_headers.ContentType

"text/html"

Result.parsed_headers.ContentLength

"12541"

Result.parsed_headers.Date

"Wed, 30 Jun 2004 14:36:12 GMT"

Result.parsed_headers.Server

"Microsoft-IIS/5.0"

Note : A HTTP GET is different from a HTTP POST in two significant ways. Some devices may restrict the total length of a URL to 128 characters, which may trim the arguments appended by a GET command. There is no such restriction with POST commands. You may save (bookmark) and refresh URLs formatted through a HTTP GET command. The arguments sent by a HTTP POST command are not saved in a bookmark.

Supported By

Alpha Five Version 6 and Above

Examples

Search Amazon.com for a book.

dim bookname as C

bookname = ui_get_text("book name", "What book are you looking for?")

dim req_body as C

req_body = "url=index%3Dstripbooks&field-keywords=" + urlencode(bookname) + "&go.x=1&go.y=1&go=Go"

dim amazon_search as P

amazon_search =

http_post("http://www.amazon.com/exec/obidos/search-handle-form/103-9603918-793183", req_body)

See Also

Internet Functions and Methods