ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

This content has been translated automatically.  Click here  to view the French version.
Help / WLanguage / WLanguage functions / Communication / HTTP functions
  • Header of HTTP request
  • Managing the errors of Web server
  • Operating mode of HTTPRequest/HTTPGetResult with a destination
  • Retrieval
WINDEV
WindowsLinuxJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac Catalyst
Others
Stored procedures
Retrieves the result or the header of last HTTP request run. This request was initiated by HTTPRequest or by HTTPSendForm.
// Récupération des éléments de la page Web "www.pcsoft.fr"
ResLancement = HTTPRequest("http://www.pcsoft.fr")
IF ResLancement = True THEN
	ResCode is string = HTTPGetResult()
	Info("Code HTML : " + ResCode)
	ResEntête is string = HTTPGetResult(httpHeader)
	Info("Entête : " + ResEntête)
	ResCookie is string = HTTPGetResult(httpCookie)
	Info("Cookie : " + ResCookie)
END
// Exemple de traitement d'erreur renvoyée par le serveur Web
Url is string 
Res_HTTP is string
ErreurHTTP is string
Url = "http://www.amazon.fr/s/ref=nb_ss?__mk_fr_FR=AMAZON&url" + ...
	"=search-alias=aps&field-keywords=2746049805"

// Envoi de la requête sur le serveur amazon
IF HTTPRequest(Url) THEN
	// La requête a pu être envoyée, il s'agit d'une URL valide
	Res_HTTP = HTTPGetResult()
	IF Length(Res_HTTP) = 0 THEN
		// Il y a eu une erreur du serveur Web, 
		// le détail de l'erreur est dans l'entête de la page
		ErreurHTTP = HTTPGetResult(httpHeader)
		Error(ErreurHTTP)
	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:
httpCookieBlock of cookies (extracted from the HTTP headers).
Java This constant is not available.
httpHeaderHeader of last HTTP request.
httpResult
(Default value)
Result of last HTTP request.
Warning: In this case, in Unicode, <Résultat> 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:
ResLancement = HTTPRequest("http://www.pcsoft.fr")
The retrieved header is:
HTTP/1.1 200 OK<\r><\n>
Date: Tue, 10 Jul 2001 13:19:08 GMT<\r><\n>
Server: 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>
Connection: 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
Server: Server
x-amz-id-1: 1KR8DDF5DV380D14DHTC
x-amz-id-2: pU0oo3rO/L+5kLNg4Yc4MPd0jF3qwyEI4nGaOhMgYkk=
Location: http://www.amazon.fr/WinDev-14-fondamentaux-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
WINDEVUser code (UMC)

Operating mode of HTTPRequest/HTTPGetResult with a destination

When a destination file is specified by HTTPDestination:
  • HTTPGetResult with the httpResult constant always returns an empty string ("").
  • HTTPGetResult with the httpHeader constant always returns the header of the HTTP response. This header is not saved in the destination file: only the data is saved.
When the request is over, the destination is canceled and HTTPRequest operates as usual.

Retrieval

HTTPGetResult can also be used to retrieve an image or a binary document (see the Example).
Component: wd300com.dll
Minimum version required
  • Version 9
This page is also available for…
Comments
Video HTTPGetResult
https://youtu.be/ciokqNgeaFc
https://windevdesenvolvimento.blogspot.com/2019/03/dicas-2033-windev-webservice-23.html
//
HTTPRequest("http://www.NOMESERVIDOR.com.br/estudos/teste.rar")
bufFer_retorno is Buffer= HTTPGetResult()
sBaixar_arquivo is string="c:\temp\teste.rar"
bRetorno is boolean=fSaveBuffer(sBaixar_arquivo,bufFer_retorno)
amarildo
04 Mar. 2019

Last update: 03/27/2025

Send a report | Local help