0
\$\begingroup\$

I will like to separate into different vars some information from a HTTP response, at the moment I'm just printing to the serial port the raw data, using:

Serial.print((const char*) Ethernet::buffer + off);

And that prints:

HTTP/1.1 200 OK
Date: Wed, 21 Nov 2012 22:47:21 GMT
Server: Apache
Vary: Accept-Encoding
Connection: close
Content-Type: text/html

Temp = 28...

I wonder how can I extract the information I need for later analysis, like the HTTP response code (200), the date, and the value of Temp, how can I extract this values into variables?

\$\endgroup\$
2
  • \$\begingroup\$ Parsing HTTP header strings in what looks like C++ seems somewhat remote to electronic design, even if it's on an embedded board. \$\endgroup\$
    – Kaz
    Nov 29, 2012 at 2:11
  • 2
    \$\begingroup\$ This might be a pure software problem if it were implemented on a more capable platform, but given the extreme resource limitations of an ATMEGA328, especially when running a TCP stack, it may be necessary to code the string parsing with unusual efficiency - ie, using the standard library functions may not be wise. Though if it works and you don't need to do anything else, fine. \$\endgroup\$ Dec 19, 2012 at 16:39

2 Answers 2

2
\$\begingroup\$

I had a look at the documentation, and it seems that you get the HTTP response from the Ethernet library, but you need to extract the information by other means.

I see two possibilities: (a) you parse the answer using C/C++ standard functions, or (b) you use a library created by somebody else. I found two libraries that may help you: this and this. Have a look at them and tell us how it goes with them.

\$\endgroup\$
0
\$\begingroup\$

What @Kaz said - this is a software problem not an electronics one...

However, a good start would be to look through the nweb server source code, that's about the neatest little web server I've seen.

\$\endgroup\$

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.