Parsing HTTP GET request

I am trying to store the HTTP request information that is generated into a document (most likely will be a CSV or XML file). I have created a web page that is being stored on an SD card. This web page has a form that a user will be filling out and the output from the form will be stored within a file, so it can be used at a later time.

I am able to get the Arduino to output the URL with all the values and can be seen using the serial monitor. The issue is that I get additional information that I do not need. What I am looking to do is just return the URL with values and hopefully be able to parse this information to something that I can store it within either a CSV or XML file.

I have searched Google for an answer, but all I could not find any examples of individuals storing data from the URL into a file.

The output that I currently have the Arduino outputting looks like this:

GET /?q1time=1&q2time=2&q3time=1&q4time=2&program1=1&program2=2&program3=&program4=4&program5=5

Host: 192.168.x.xx

Connection: keep-alive

The URL will included around 40 values that a user will need to select from the form on the website.

Any assistance pointing me in the right direction on how to do this would be greatly appreciated.

If it helps, here is the code that I have so far:

#include <Dhcp.h>
#include <Dns.h>
#include <Ethernet2.h>
#include <EthernetClient.h>
#include <EthernetServer.h>
#include <EthernetUdp2.h>
#include <SD.h>
#include <WString.h>
#include <string.h>

// Enter a MAC address and IP address for your controller below.
// The IP address will be dependent on your local network:
byte mac[] = { 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA };
IPAddress ip(192, 168, x, xx);

// Initialize the Ethernet server library
// with the IP address and port you want to use
// (port 80 is default for HTTP):
EthernetServer server(80);

File webFile;

void setup()
    Ethernet.begin(mac, ip);  // initialize Ethernet device
    server.begin();           // start to listen for clients
    Serial.begin(9600);       // for debugging
    // initialize SD card
    Serial.println("Initializing SD card...");
    if (!SD.begin(4)) {
        Serial.println("ERROR - SD card initialization failed!");
        return;    // init failed
    Serial.println("SUCCESS - SD card initialized.");
    // check for index.htm file
    if (!SD.exists("index.htm")) {
        Serial.println("ERROR - Can't find index.htm file!");
        return;  // can't find index file
    Serial.println("SUCCESS - Found index.htm file.");

void loop() {
  // listen for incoming clients
  EthernetClient client = server.available();
  if (client) {
    // an http request ends with a blank line
    boolean currentLineIsBlank = true;
    while (client.connected()) {
      if (client.available()) {
        char c =;

  String req = client.readStringUntil('\r');
        // 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) {
          // send a standard http response header
          client.println("HTTP/1.1 200 OK");
          client.println("Content-Type: text/html");
          client.println("Connection: close");  // the connection will be closed after completion of the response
                    // send web page
                    webFile ="index.htm");        // open web page file
                    if (webFile) {
                        while(webFile.available()) {
                            client.write(; // send web page to client
        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;
    // give the web browser time to receive the data
    // close the connection:

Thanks for reading this.

You might get some help here:

It doesn't help you at the moment, but if you move on to WLAN, the ESP8266 library class ESP8266WebServer has an arg() method which allows you parse the querystring you get back from the browser.

char c =;

String req = client.readStringUntil('\r');

Having two methods reading data from the same stream is a recipe for disaster.

Since you KNOW that the data you want is in the String that contains/starts with GET, just ignore the other.

(Or ET, if you don't stop using two read methods).