-->
Page 1 of 1

How to GET binary data from a website?

PostPosted: Wed Aug 03, 2016 8:09 pm
by JimDrew
The subject says it all. How can you get a binary file from a website? I need to download a small file that is an encryption key. I have tried various forms of GET /, but it seems that this is for use with HTML style headers, not binary data.

Any examples? Thanks!

Re: How to GET binary data from a website?

PostPosted: Thu Aug 04, 2016 4:24 am
by eduperez
Even if you are asking the server for a binary file, there is always some HTTP headers added to the answer; you can find more info about the HTTP protocol here: https://www.ntu.edu.sg/home/ehchua/programming/webprogramming/HTTP_Basics.html.

If you do not want to write a full HTTP parser, I guess you can check the status code on the first bytes of the answer ("HTTP/1.1 200 OK") and then skip until you encounter an empty line.

See the "Testing HTTP Requests" > "Telnet" section in that document to see how you can debug from a computer what the server is sending to your ESP.

Re: How to GET binary data from a website?

PostPosted: Thu Aug 04, 2016 11:27 am
by JimDrew
Thanks... this information is really helpful for those (like me) that don't know anything about how GET and POST work.

I can just parse the HTTP data and look for the blank line to start my binary read.