0

I send http get request to web server with my ESP8266. And my server returns;

HTTP/1.1 200 OK Date: Sat, 22 Jul 2017 11:16:10 GMT Server: Apache/2.4.10 (Raspbian) Content-Length: 16 Connection: close Content-Type: text/html; charset=UTF-8

Important Part

As you can understand i need "Important Part" to for assign a variable. I don't want to use external library. I think if we say whole message is equal x, and HTTP response part is y, if we do x - y we find the "Important Part" right?

How can we do it, how can i read until charset=UTF-8 to get payload ?

3
  • Why not use an external library? There are many portable C-libraries which work out of the box, e.g. github.com/nodejs/http-parser (example: gist.github.com/ry/155877) Commented Jul 22, 2017 at 19:36
  • Look at the HTTP protocol, there should be two carriage return line feeds between the headers and body. Read and discard until you find that. Commented Jul 22, 2017 at 22:37
  • What firmware/SDK do you use (Arduino, NodeMCU, etc.)? Commented Jul 23, 2017 at 11:15

1 Answer 1

1

You are looking for 2 CRLFs in row (HTTP spec). Start reading from the beginning of your receive buffer, once you encounter 0xD 0xA 0xD 0xA, you are at your Important Part.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.