Read HTTP Post?

I can’t seem to find any good information on this topic after quite a bit of googling. I’m trying to make my Arduino with the Ethernet shield accept a HTTP Post, and parse that post request out.

What I’m looking to do, essentially is;

Send a HTTP post from cURL, or my browser to my Arduino with for example “data=1,2,3,4,5,6,7&foo=bar” and have data and foo parsed out individually for consumption later.

The POST data is after the blank line in the request. This subject might help.,87656.0.html

And in a request the line separator is the two-byte sequence 0x13,0x10 - so you look for the first occurrence of 0x13,0x10,0x13,0x10 and the body starts after it.

Thanks for the help. I have this bit of code now,

  char inbuffer[256]; //256 characters should be okay.
  int index = 1;
  if(client) {
   while (client.connected() && client.available()) {
  	  char c =;
  	  inbuffer[0] = c; //the first character gets cut off in while loop. get it now.
      while(client.available()) {
        if(index < 255) {
          inbuffer[index] = c;
          inbuffer[index] = '\0';
      Serial << "\n";
      Serial << F("Read: ") << inbuffer << "\n";

and I’m calling it with curl -d “test=foo&bar=foo” -v

Except, it seems to crash the arduino or something. If I have the inbuffer lines in the sketch, the arduino won’t work and doesn’t accept any HTTP requests. If I take them out it bounces back to life. Here’s the full in progress sketch, if it helps.

Did you try the code that zoomkat posted in the link I posted above?

Did you try the code that zoomkat posted in the link I posted above?

Yes, I’ve gone as far as just copying the code, and I never reach inside the if (c == ‘\n’ && currentLineIsBlank) { part.

boolean post_handler(TinyWebServer& web_server) {
  Serial << F("Post Event") << "\n";
  Client& client = web_server.get_client();
if (client) {
      // an http request ends with a blank line
      boolean currentLineIsBlank = true;
      while (client.connected()) {
        while(client.available()) {
          char c =;
          // if you've gotten to the end of the line (received a newline
          // character) and the line is blank, the http request has ended,
          // so you can send a reply
          if (c == '\n' && currentLineIsBlank) {

  // Here is where the POST data is.  

            Serial.println("Sending response");
            // send a standard http response header
            // client.println("HTTP/1.0 200 OK");
            // client.println("Content-Type: text/html");
            // client.println();
            // client.println("<HTML><BODY>TEST OK!");


          else if (c == '\n') {
            // you're starting a new line
            currentLineIsBlank = true;
          else if (c != '\r') {
            // you've gotten a character on the current line
            currentLineIsBlank = false;

  return true;