Get info code about connection to an URL
Get info code about connection to an URL
Hello,
i would like to get an info code about the connection to an URL but i don't understand hurl plugin.
Example:
200 : ok
404 : not found
etc...
thanks for your help
i would like to get an info code about the connection to an URL but i don't understand hurl plugin.
Example:
200 : ok
404 : not found
etc...
thanks for your help
Re: Get info code about connection to an URL
yeah hURL is a mess .. took me long time to understand back then
here is an example who will receive 404
here is an example who will receive 404
Code: Select all
@REQUIRE "hurl"
; this function will be called whenever there is new data
Function p_WriteData(data$)
DebugPrint(data$)
EndFunction
; create easy object and configure it
e = hurl.Easy({URL = "https://www.google.com/NONEXISTING", WriteFunction = p_WriteData})
e:setopt_http_version(#CURL_HTTP_VERSION_1_1)
e:setopt_customrequest("GET")
e:perform()
; destroy easy object
responsecode = e:getinfo_response_code()
e:close()
DebugPrint("error code : "..responsecode)
End
Christos
Re: Get info code about connection to an URL
It work perfect!!!
Not easy code but very interesting and usefull, i will investigate the hurl plugin.
Thanks a lot plouf!!!
Possibility to remove output window please?
Not easy code but very interesting and usefull, i will investigate the hurl plugin.
Thanks a lot plouf!!!
Possibility to remove output window please?
Re: Get info code about connection to an URL
Yes, MorphOS open an output window with the content of the URL (file).
Re: Get info code about connection to an URL
Its the
DebugPrint() command... Part of my example
DebugPrint() command... Part of my example
Christos
Re: Get info code about connection to an URL
No, i have removed the Debugprint...
e.perform() seems open the file of the url in an output window...
e.perform() seems open the file of the url in an output window...
Re: Get info code about connection to an URL
Did you remove the debug output from the write function too? In any case there's no output window by default.
Re: Get info code about connection to an URL
@jPV: yes...
This is a code wich normally just show responsecode:
I have many caracters before the responsecode on MorphOS...
This is a code wich normally just show responsecode:
Code: Select all
@REQUIRE "hurl"
e = hurl.Easy({URL = "https://www.google.com"})
e:perform()
responsecode = e:getinfo_response_code()
e:close()
DebugPrint("error code : "..responsecode)
EndRe: Get info code about connection to an URL
If you don't provide a write function, it will output to stdout (shell). So it works as it should and if you don't want any output or store any data to anywhere, give it a function that does nothing.
This is a very minimal example:
e = hurl.Easy({URL = "https://www.google.com", WriteFunction = Function() EndFunction})
Here's what's told in the libcurl manual (googled it):
"libcurl offers its own default internal callback that takes care of the data if you do not set the callback with CURLOPT_WRITEFUNCTION. It simply outputs the received data to stdout."
This is a very minimal example:
e = hurl.Easy({URL = "https://www.google.com", WriteFunction = Function() EndFunction})
Here's what's told in the libcurl manual (googled it):
"libcurl offers its own default internal callback that takes care of the data if you do not set the callback with CURLOPT_WRITEFUNCTION. It simply outputs the received data to stdout."