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.
http://arduino.cc/forum/index.php/topic,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 = client.read();
  	  inbuffer[0] = c; //the first character gets cut off in while loop. get it now.
      Serial.write(client.read());
      while(client.available()) {
        Serial.write(client.read());
        if(index < 255) {
          inbuffer[index] = c;
          index++;
          inbuffer[index] = '\0';
        }
      }
      Serial << "\n";
      Serial << F("Read: ") << inbuffer << "\n";
   }
  }

and I’m calling it with curl -d “test=foo&bar=foo” http://192.168.1.25/ir -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?

SurferTim:
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) {
      Serial.println("Client");
      // an http request ends with a blank line
      boolean currentLineIsBlank = true;
      while (client.connected()) {
        while(client.available()) {
          char c = client.read();
          // 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.  
            while(client.available())
            {
               Serial.write(client.read());
            }
            Serial.println();

            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!");

            web_server.send_error_code(200);
            web_server.send_content_type("text/plain");
            web_server.end_headers();

            client.stop();
          }
          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;
          }
        }
      }
      Serial.println("Disconnected");
    }


  return true;
}