You are not logged in.
Pages: 1
I am using TWinHTTP, specifically Get and Put methods which seem to suppress any exceptions (404 etc) just returning an empty payload. I would like to handle / be aware of error conditions such as these in my application however. What would be the correct way of facilitating this?
Thanks
Offline
I think you'll have to call Request method instead. Get/Put calls are just handy wrappers around it but without HTTP return value.
Offline
I would appreciate an example of Request method with GET and POST method, i've tried
res : Integer;
outHDr, OutData : SockString;
res := fclient.Request('http://localhost:3002/testroute', 'GET', 0, Hdr.Header, EmptyStr, EmptyStr, outHDr, OutData);
where Hdr.Header provides Header string collection (works for GET method)
same url used for GET method and works but for Request method returns a 404.
I could not see any example or documentation outlining the Request method in detail.
Thanks
Offline
> I would appreciate an example of Request method with GET and POST method, i've tried
var
http: TWinHTTP;
res: Integer;
resHdr, resData, resDataGet: SockString;
begin
resDataGet := TWinHTTP.Get('www.google.com');
mmo1.Lines.Add(resDataGet);
http := TWinHttp.Create('www.google.com', '80', False);
res := http.Request('', 'GET', 0, '', '', '', resHdr, resData);
if res = 200 then
mmo1.Lines.Add(resData);
Offline
Thanks igors233, I should have just passed the relative route to the request instead of full URI. Example much appreciated.
Offline
Thanks Arnaud, did not know about TURI. Will have a look. There are loads of functionality around the periphery of mormot that is very useful but with very little mention / examples. I find myself having to ask questions here due to this. I must give thanks for an awesome framework though, has already saved me loads of time:)
Offline
Pages: 1