Page 1 of 1

http Headers without content?

Posted: Mon Oct 21, 2024 1:35 am
by vwidmer
How can I get the http headers without downloading the content?

Thanks

Re: http Headers without content?

Posted: Mon Oct 21, 2024 2:57 am
by idle
On phone, you can use the header only flag with a get see doc
https://www.purebasic.com/documentation ... emory.html

edit: Glad I checked as I had a bug, I was returning 100 continue

Code: Select all

HttpRequest = HTTPRequestMemory(#PB_HTTP_Get, "https://atomicwebserver.com/index.html",0,0,#PB_HTTP_HeadersOnly)
If HttpRequest
  Debug "StatusCode: " + HTTPInfo(HTTPRequest, #PB_HTTP_StatusCode)
  Debug "headers: " + HTTPInfo(HTTPRequest,#PB_HTTP_Headers)
  FinishHTTP(HTTPRequest)
Else
  Debug "Request creation failed"
EndIf


Re: http Headers without content?

Posted: Mon Oct 21, 2024 2:50 pm
by Piero
vwidmer wrote: Mon Oct 21, 2024 1:35 am I just put stuff here and there and sometimes like magic it works.
You're talking about headers but I liked the signature :lol:

Re: http Headers without content?

Posted: Tue Oct 22, 2024 12:34 am
by vwidmer
@idle: Thank you very much!! Not sure how I missed that but it is working as need.

Re: http Headers without content?

Posted: Tue Oct 22, 2024 12:35 am
by vwidmer
Piero wrote: Mon Oct 21, 2024 2:50 pm
vwidmer wrote: Mon Oct 21, 2024 1:35 am I just put stuff here and there and sometimes like magic it works.
You're talking about headers but I liked the signature :lol:
Magic gets better with practice :lol:

Re: http Headers without content?

Posted: Tue Oct 22, 2024 3:11 am
by idle
vwidmer wrote: Tue Oct 22, 2024 12:34 am @idle: Thank you very much!! Not sure how I missed that but it is working as need.
Thank you for not noticing as I was able to fix a bug in my code. :lol: