ResendPostRequest

Description

Sends the request again. The function is called when both of the following conditions are met:

  1. Use the PostDataStart function to send the request.

  2. When the PostDataStart function or the PostDataEnd function returns error code -22.

Applies to

HTTPClient object

Syntax

objectname.ResendPostRequest()

Argument

Description

objectname

The name of the object from which you want to resend the request.


Return value

Integer.

1 -- Success.

-1 -- General error.

-2 -- Invalid URL.

-3 -- Cannot connect to the Internet.

-4 -- Timed out.

-5 -- Code conversion failed.

-6 -- Unsupported character sets.

-7 -- Certification revocation checking has been enabled, but the revocation check failed to verify whether a certificate has been revoked. The server used to check for revocation might be unreachable.

-8 -- SSL certificate is invalid.

-9 -- SSL certificate was revoked.

-10 -- The function is unfamiliar with the Certificate Authority that generated the server certificate.

-11 -- SSL certificate common name (host name field) is incorrect, for example, you entered www.appeon.com and the common name on the certificate says www.demo.appeon.com.

-12 -- SSL certificate date that was received from the server is invalid. The certificate has expired.

-13 -- The certificate was not issued for the server authentication purpose.

-14 -- The application experienced an internal error when loading the SSL libraries.

-15 -- More than one type of errors when validating the server certificate.

-16 -- The server requires the client to provide a certificate.

-17 -- The client certificate has no private key.

-18 -- The private key in the client certificate is wrong.

-19 -- A security error has occurred. Possible cause: The client does not support the SSL/TLS version required by the server. For example: Client does not support TLS 1.3 when server requires TLS 1.3.

-20 -- Response is unrecognizable. Normally this is because the HTTP version does not match with the version required by the server.

-21 -- TLS 1.3 error. The server does not support TLS 1.3.

-22 -- The request needs to be resent. Only the ResendPostRequest function can be called at this time.

-24 -- Failed to set the authentication scheme.

-25 -- Failed to decompress data.

Examples

The following example resends the request.

HTTPClient lhc_Client
lhc_Client = Create HTTPClient
lhc_Client.ResendPostRequest()

The following example shows that when using the PostDataStart function to send the request and this function returns error code -22, the ResendPostRequest function sends the request again.

string ls_User,ls_PassWord,ls_Url,ls_Method
long ll_rtn,ll_Code
Integer  li_Scheme[]
blob lbb_Data
HTTPClient lhc_Client
lhc_Client = Create HTTPClient

ls_Method = "POST"
lhc_client = create HttpClient
ls_User = "guest"
ls_PassWord = "guest"
ls_Url = "https://csharpserver.appeon.com:8001/"
ll_rtn = lhc_Client.SetCredentials(False, 0, ls_User, ls_PassWord)

ll_rtn = lhc_Client.SendRequest( ls_Method, ls_Url )
ll_Code = lhc_Client.GetResponseStatusCode()
messagebox( "message",'Basic SendRequest("POST") = ' + String(ll_rtn) + " Code:" +String(ll_Code))

lbb_Data = Blob("TlRMTVNTUAADAAAAGAAYAK4AAAAYABgAxgAAAB4AHgBYAAAAGgAaAHYAAAAeAB4AkAAAABAAEADeAAAAFYKI4goAYUoAAAAPEfQVzpqoX2gJ6mlC68O0tTgAMAAzADkAUABBAE4ARwBDAEgAVQBHAFUAQQBOAGEAZABtAGkAbgBpAHMAdAByAGEAdABvAHIAOAAwADMAOQBQAEEATgBHAEMASABVAEcAVQBBAE4AtU4JLOSpoeAAAAAAAAAAAAAAAAAAAAAAcadkZTtacusLDLedDQTLnBF8r+qYLPceXn5MPzyzjrtzLU84RO1FJg==")
lhc_Client.SetRequestHeader("Content-Type", "multipart/form-data; boundary--------------------------359875084413580694217125")
lhc_Client.SetRequestHeader("Content-Length", string(len(lbb_Data)))

ll_rtn = lhc_Client.PostDataStart( ls_Url )
messagebox("message", 'Basic PostDataStart( url )= ' + String(ll_rtn))
IF ll_rtn = -22 THEN
 ll_rtn = lhc_Client.ResendPostRequest()
 //wf_output( 'Basic ResendPostRequest( )= ' + String(ll_rtn), False)
End If
If ll_rtn = 1 Then
  // send the request
  ll_rtn = lhc_Client.PostData(lbb_Data, Len(lbb_Data) * 2)
  messagebox("message", 'Basic PostData( data )= ' + String(ll_rtn))
  // Finish sending the message. This interface may return error code -22.
  IF ll_rtn = -22 THEN
  //resend the request
   ll_rtn = lhc_Client.ResendPostRequest()
   messagebox( "message",'Basic ResendPostRequest( )= ' + String(ll_rtn))
  End If
  ll_rtn  = lhc_Client.PostDataEnd()
  messagebox("message", 'Basic PostDataEnd()= ' + String(ll_rtn))
END IF

See also

SetCredentials

GetSupportScheme