ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

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
  • Limits
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac CatalystUniversal Windows 10 App
Others
Stored procedures
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:
httpCookieBlock of cookies (extracted from the HTTP headers).
Universal Windows 10 AppJava This constant is not available.
httpHeaderHeader 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
WINDEVWEBDEV - Server codeReports and QueriesUniversal Windows 10 AppiPhone/iPadIOS WidgetMac CatalystUser code (UMC)Ajax

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).
Universal Windows 10 App

Limits

  • The proxy used is the one of Internet Explorer.
  • The certificates cannot be ignored.
  • The protocol returned by HTTPGetResult with the httpHeader constant is always 1.1 (even if the server is 1.0).
Component: wd290com.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
Exemplo httpgetresult
//busca cep
_manda_Cep is int=SAI_cep_busca
(SAI_uf,SAI_cidade,SAI_bairro,SAI_tipo,SAI_rua)=busca_cep(_manda_Cep)
//----
PROCEDURE busca_cep(n_cep_recebe is int)
Resultadoxml is string=""
ok is boolean=HTTPRequest("http://cep.republicavirtual.com.br/web_cep.php?cep="+n_cep_recebe+"&formato=xml")
IF ok=True THEN
Resultadoxml=HTTPGetResult()
ELSE
Resultadoxml=""
Info("cep nao existe"+n_cep_recebe)
END
sNo_xml is string=XMLExtractString(Resultadoxml,"webservicecep")
suf is string=XMLExtractString(sNo_xml,"uf")
suf=Upper(remove_acento(suf))
RESULT(suf,sCidade,sBairro,sTipo,sRua)

// Blog com video e exemplo completo

http://windevdesenvolvimento.blogspot.com.br/2016/01/windev21-curso-225-cep-republica.html
De matos AMARILDO
15 Jan. 2016
Examples
Ex01: Retorna Html
#####################################################
Code Button:

Url is string = "http://www.informaticon.com.br"
ok is boolean = httprequest(url)
if ok = true
info(ok )
retorno is string = httpgetresult()
else
info(errorinfo())
end

Ex02: Retorna Header do Html
#####################################################
Code Button:

Url is string = "http://www.informaticon.com.br"
ok is boolean = httprequest(url)
if ok = true
info(ok )
retorno is string = httpgetresult(httpHeader)
else
info(errorinfo())
end

Ex03: Retorna Cookie
#####################################################
Code Button:

Url is string = "http://www.informaticon.com.br"
ok is boolean = httprequest(url)
if ok = true
info(ok )
retorno is string = httpgetresult(httpCookie)
else
info(errorinfo())
end

Ex04: Retorna html
#####################################################
Code Button:

Url is string = "http://www.informaticon.com.br"
ok is boolean = httprequest(url)
if ok = true
info(ok )
retorno is string = httpgetresult(httpResult)
else
info(errorinfo())
end

Ex05: Retorna uma imagem (download de arquivo)
#####################################################
Code Button:

ArquivoBaixado is buffer

Url is string = "http://www.informaticon.com.br/j/images/stories/neri.jpg"

ok is boolean = httprequest(url)

if ok = true
ArquivoBaixado = httpgetresult()
else
info(errorinfo())
end

fSaveBuffer("c:\fotodonerigaldeiro.jpg",ArquivoBaixado)

Ex06: Retorna uma executavel (download de arquivo)
#####################################################
Code Button:

ArquivoBaixado is buffer

Url is string = "http://www.7-zip.org/a/7z920.exe"

ok is boolean = httprequest(url)

if ok = true
ArquivoBaixado = httpgetresult()
else
info(errorinfo())
end

fSaveBuffer("7z920.exe",ArquivoBaixado)

Ex07: SOAP
#####################################################
http://forum.pcsoft.fr/fr-FR/pcsoft.br.windev/121-httprequest-envelope-soap/read.awp

Ex08: Download + ProgressBar
#####################################################
HTTPProgressBar(PROGBAR_download)
arquivo is boolean = HTTPRequest("http://www.amarildomatos.com.br/clientes_arquivos/dll262.zip")
HTTPProgressBar("")
adrianoboller
28 Feb. 2015

Last update: 05/26/2022

Send a report | Local help