West Wind Internet and Client Tools
Resubmitting a failed HTTPGet
Gravatar is a globally recognized avatar based on your email address. Resubmitting a failed HTTPGet
  Eddie Caldwell
  All
  Apr 1, 2019 @ 10:48am

If a HTTPGet returns an error because of something downstream I would like to retry it once. Can I just re-submit the HTTPGet like below or do I need to do the addpostkeys again?

Thanks!!

loHTTP			= createobject([wwHTTP])
loHTTP.nConnectTimeout 	= 30
loHTTP.nHTTPConnectType	= 0
loHttp.AddPostKey([secret]	,xSecret)
loHttp.AddPostKey([response]	,xResp)
loHttp.AddPostKey([remoteip]	,xIP)	
cResult 	= loHTTP.HTTPGet([https://www.google.com/recaptcha/api/siteverify])
if loHttp.nError <> 0
	if lohttp.cerrormsg  = [The server returned an invalid or unrecognized response]
		cResult= loHTTP.HTTPGet([https://www.google.com/recaptcha/api/siteverify])
		endif
	endif
Gravatar is a globally recognized avatar based on your email address. re: Resubmitting a failed HTTPGet
  Rick Strahl
  Eddie Caldwell
  Apr 1, 2019 @ 01:58pm

It's recommended that you create a new instance of wwHttp for each request you make to ensure that you are running a completely clean instance.

The POST buffer is cleaned out when the request completes so no the data is not stored.

Should be easy enough to create a method that creates the HTTP request or runs the request in a self-contained reusable fashion.

+++ Rick ---

© 1996-2024