PC SOFT

ONLINE HELP
FOR WINDEV, WEBDEV AND WINDEV MOBILE

Home | Sign in | English US
  • Properties specific to the description of httpRequest variables
  • Notes
  • Limits
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadApple WatchUniversal Windows 10 AppWindows Mobile
Others
Stored procedures
The httpRequest type is used to retrieve the advanced characteristics of an HTTP/HTTPS request. The characteristics of this HTTP/HTTPS request can be defined and modified by several WLanguage properties.
Note: See Declaring a variable for more details.
Versions 22 and later
Android Widget This type of variable is now available in Android Widget mode.
Android This type of variable is now available for the Android applications.
WEBDEV - Browser code This type of variable is now available in browser code.
New in version 22
Android Widget This type of variable is now available in Android Widget mode.
Android This type of variable is now available for the Android applications.
WEBDEV - Browser code This type of variable is now available in browser code.
Android Widget This type of variable is now available in Android Widget mode.
Android This type of variable is now available for the Android applications.
WEBDEV - Browser code This type of variable is now available in browser code.
Example
cMyRequest is httpRequest
cMyRequest..URL = "http://www.windev.com"
cMyResponse is httpResponse = HTTPSend(cMyRequest)
IF ErrorOccurred THEN
Error(ErrorInfo(errFullDetails))
ELSE
Info(cMyResponse..Content)
END
Remarks

Properties specific to the description of httpRequest variables

The following properties can be used to handle an HTTP/HTTPS request:
Property nameType usedEffect
UserAgentCharacter stringIdentifies the client. The default value is "PC SOFT Framework".Identifies the client. By default, the value corresponds to the application name.
The response content may depend on the user agent (for example, different pages are required by a request performed from a Palm Pilot and a request performed from a PC browser). In this case, see the documentation of user agent for more details.
WEBDEV - Browser code Not available.
Versions 22 and later
AuthToken
New in version 22
AuthToken
AuthToken
AuthToken variableToken for accessing a Webservice that will be used in case of authentication via the OAuth 2.0 protocol. This access token was retrieved by AuthIdentify.
WEBDEV - Browser code Not available.
UploadProgresshttpProgress variableNotification of progress status when uploading POST data.
DownloadProgresshttpProgress variableNotification of progress status of download.
ContentTypeCharacter stringType of content of HTTP message that will be sent to the server. This property is taken into account only if the send method (..Method) allows it.
By default, the message type corresponds to: "application/x-www-form-urlencoded".
However, you have the ability to use any value, for example: "text/xml", "application/javascript", "application/json", "application/xml", "image/jpeg", ...
To send rough data that will be read at once by the WEBDEV application server, use the following types:
  • "application/byte-stream".
  • "text/xml".
ContentBufferHTTP message that will be sent to the server. This property is taken into account only if the send method (..Method) allows it.
The message to send must comply with the HTTP protocol used. By default, if this property is specified and if it is not empty, the method used is a POST request ; otherwise, it is a GET request.
TimeoutInteger ou DurationMaximum response time-out (expressed in milliseconds). This property can correspond to:
  • an integer corresponding to the number of milliseconds,
  • a Duration variable,
  • Versions 23 and later
    the direct indication of duration (1 s or 10 ms for example).
    New in version 23
    the direct indication of duration (1 s or 10 ms for example).
    the direct indication of duration (1 s or 10 ms for example).
This property is set to 20 seconds by default.
Note: The time-out defined by HTTPTimeOut has no influence on this property.
WEBDEV - Browser code Not available.
HeaderAssociative array of character stringsKey/Value set of headers to send.
Example for using this property:
cMyRequest..Header["Authorization"] = ...
" WSSE profile=""UsernameToken"""
cMyRequest..Header["X-WSSE"] = ...
"UsernameToken Username=blahblah "
cMyRequest..Header["Cache-Control"] = " no-cache"
IgnoreErrorInteger constantSpecifies the ignored errors. Corresponds to a constant or to a combination of constants:
  • httpIgnoreInvalidCertificate: The certificate is ignored.
  • httpIgnoreInvalidCertificateName: The site name specified in the certificate is ignored.
  • httpIgnoreExpiredCertificate: The certificate date is ignored.
  • Versions 21 and later
    httpIgnoreRedirection: The redirection to a page is ignored.
    New in version 21
    httpIgnoreRedirection: The redirection to a page is ignored.
    httpIgnoreRedirection: The redirection to a page is ignored.
  • httpIgnoreRedirectToHTTP: The redirection to a non-secure server is allowed.
  • httpIgnoreRedirectToHTTPS: The redirection to a secure server is allowed.
  • httpIgnoreRevocation: The check in the list of revoked certificates is ignored.
Versions 22 and later
AndroidAndroid Widget Only the following errors are supported: httpIgnoreExpiredCertificate, httpIgnoreInvalidCertificate, httpIgnoreInvalidCertificateName, httpIgnoreRevocation, httpIgnoreRedirection.
New in version 22
AndroidAndroid Widget Only the following errors are supported: httpIgnoreExpiredCertificate, httpIgnoreInvalidCertificate, httpIgnoreInvalidCertificateName, httpIgnoreRevocation, httpIgnoreRedirection.
AndroidAndroid Widget Only the following errors are supported: httpIgnoreExpiredCertificate, httpIgnoreInvalidCertificate, httpIgnoreInvalidCertificateName, httpIgnoreRevocation, httpIgnoreRedirection.
WEBDEV - Browser code Not available.
MethodInteger constantHTTP method used:
  • httpCopy: COPY method.
  • httpDelete: DELETE method.
  • httpGet: GET method.
  • httpHead: HEAD method.
  • httpPatch: PATCH method.
  • httpPost: POST method.
  • httpPut: PUT method.
If ..Content is not empty, the httpPost method is used by default. Otherwise, the httpGet method is used.
PasswordCharacter stringPassword associated with the user name (empty string by default). Used to access a page with a protected URL. Caution: The password is not encrypted when it is sent on Internet.
Note: If ..UserName and ..Password are specified, the corresponding "Authorization:Basic" is automatically generated in the request header.
Versions 21 and later
ConnectionTimeout
New in version 21
ConnectionTimeout
ConnectionTimeout
Integer ou DurationMaximum time-out for the connection expressed in milliseconds (20 seconds by default, which means 20000 milliseconds). This property can correspond to:
  • an integer corresponding to the number of milliseconds,
  • a Duration variable,
  • Versions 23 and later
    the direct indication of duration (20 s or 20000 ms for example).
    New in version 23
    the direct indication of duration (20 s or 20000 ms for example).
    the direct indication of duration (20 s or 20000 ms for example).
If the connection was not established after this time-out, the connection failed (HTTPSend will return an error, found in the httpResponse variable).
WEBDEV - Browser code Not available.
URLCharacter stringAddress of server to contact (URL address).
This URL can contain:
  • the port number for connecting to the server.
    The default value is 80 in HTTP (corresponds to a server of Web pages) and 443 in HTTPS . To specify a port number, use the following format: "<Server URL>:<Port #>". For example: http://www.windev.com:80.
  • additional parameters. These parameters can be used to perform a search or to fill a form. For example, to find "windev" on "http://www.google.com", the URL to contact will be: "http://www.google.com/search?q=windev".
Notes:
  • To specify both the port number and additional parameters, use the following format: "<Server URL>:<Port #>/<Additional Parameters>".
  • To perform a secure transaction, the URL must start with "https://". In this case, the management mode of requests is always performed by Internet Explorer (see HTTPParameter for more details).
UserCharacter stringName used to access a page with a protected URL (empty string by default). This name is used to identify the user.
Note: If ..UserName and ..Password are specified, the corresponding "Authorization:Basic" is automatically generated in the request header.
Versions 22 and later
VersionSSL
New in version 22
VersionSSL
VersionSSL
Integer constantSSL version used:
  • ProtocolDefault: Default protocol (TLS 1.2).
  • ProtocolTLS1: TLS1 protocol.
  • ProtocolTLS1_1: TLS1.1 protocol.
  • ProtocolTLS1_2: TLS1.2 protocol.
WEBDEV - Browser code Not available.

Note: These properties can be used via one of the following syntaxes:
  • <Variable Name>..<Property Name>
  • <Variable Name>.<Property Name>

Notes

  • The management of client certificates is not available.
  • Versions 21 and later
    The redirections are supported by default. To avoid supporting the redirections, use the httpIgnoreRedirection constant in ..IgnoreError.
    New in version 21
    The redirections are supported by default. To avoid supporting the redirections, use the httpIgnoreRedirection constant in ..IgnoreError.
    The redirections are supported by default. To avoid supporting the redirections, use the httpIgnoreRedirection constant in ..IgnoreError.
AndroidAndroid Widget

Limits

This type of variable is available for the devices equipped with ARM processors. A fatal error occurs if this type of variable is used with devices not equipped with ARM processors (x86, mips, ...). This type of variable is available for the devices equipped with ARM processors or using an ARM emulation. Otherwise (and on the Samsung Galaxy Tab 3 tablet), a fatal error will occur.
Minimum required version
  • Version 20
This page is also available for…
Comments
Example HTTPCreateForm + HTTPRequest + HTTPSendForm
Procedure WS_RotasGoogleMaps(enderecoOrigem is string, enderecoDestino is string) : string

IF enderecoOrigem = "" OR enderecoDestino = "" THEN
RESULT(Null)
END

//GloVoceEnderecoLongo is string
//GloVoceEndereco is string
//GloVoceNumero is string
//GloDestinoEnderecoLongo is string
//GloDestinoEndereco is string
//GloDestinoNumero is string
//GloValorBandeira01 is real
//GloValorBandeira02 is real
//GloTaxaRetorno is real
//GloTempoCarro is real
//GloDistanciaCarro is real
//GloNortelatitude is real
//GloNorteLongitute is real
//GloSullatitude is real
//GloSulLongitute is real
//GloTempoDestino is string
//GloPoligonalGoogle is string
//GloDistanciaDestino is string
//GloHtmlInstructions is string

//Limpa variaveis
GloVoceEnderecoLongo = "ERRO" //String
GloDestinoEnderecoLongo = "ERRO" //String
GloTempoDestino = "" //String
GloDistanciaDestino = "" //String
GloHtmlInstructions = "" //String
GloPoligonalGoogle = "" //String
GloDistanciaCarro = 0 //real
GloTempoCarro = 0 //real
GloNortelatitude = 0 //real
GloNorteLongitute = 0 //real
GloSullatitude = 0 //real
GloSulLongitute = 0 //real

HTTPCreateForm("GoogleMaps")
HTTPAddParameter("GoogleMaps","origin", enderecoOrigem)
HTTPAddParameter("GoogleMaps","destination", enderecoDestino)
HTTPAddParameter("GoogleMaps","language", "pt-BR")
HTTPAddParameter("GoogleMaps","region", "br")
HTTPAddParameter("GoogleMaps","units", "metric")
HTTPAddParameter("GoogleMaps","key","AIzaSyDbSVKYPwB1a-_vPbDzAr6LgAfIj4iW2hc")

cMyRequest is HTTPRequest
cMyRequest..URL = "https://maps.googleapis.com/maps/api/directions/xml"
cMyRequest..Method = httpGet // OR httpPOST

cMyResponse is httpResponse = HTTPSendForm("GoogleMaps", cMyRequest)

IF cMyResponse..StatusCode <> 200 THEN // Se não funcionou
RESULT(Null)
END

xmlGoogle is XMLDocument = XMLOpen(cMyResponse..Content, fromString)
IF NOT xmlGoogle.DirectionsResponse.status..Text ~= "OK" THEN
RESULT(Null)
END

//Lendo nos unicos
GloVoceEnderecoLongo = xmlGoogle.DirectionsResponse.route.leg.start_address
GloDestinoEnderecoLongo = xmlGoogle.DirectionsResponse.route.leg.end_address
GloTempoCarro = xmlGoogle.DirectionsResponse.route.leg.duration.value
GloTempoDestino = xmlGoogle.DirectionsResponse.route.leg.duration.text
GloDistanciaCarro = xmlGoogle.DirectionsResponse.route.leg.distance.value
GloDistanciaDestino = xmlGoogle.DirectionsResponse.route.leg.distance.text
GloPoligonalGoogle = xmlGoogle.DirectionsResponse.route.overview_polyline.points
GloNortelatitude = xmlGoogle.DirectionsResponse.route.bounds.northeast.lat
GloNorteLongitute = xmlGoogle.DirectionsResponse.route.bounds.northeast.lng
GloSullatitude = xmlGoogle.DirectionsResponse.route.bounds.southwest.lat
GloSulLongitute = xmlGoogle.DirectionsResponse.route.bounds.southwest.lng

//Loop nos nós do xml
Resultado is string
Contador is int = 1
FOR EACH legNode OF xmlGoogle.DirectionsResponse.route.leg
IF legNode..Name = "step" THEN
HTML is string = legNode.html_instructions
Distancia is int = legNode.distance.value
Resultado += Contador + ". " + HTML + " [" + Distancia + "]" + CR
Contador++
END
END

GloHtmlInstructions = Resultado

RESULT(Resultado)
adrianoboller
Jan. 13 2016