Skip to content

Instantly share code, notes, and snippets.

@janajri
Created August 29, 2015 16:37
Show Gist options
  • Save janajri/acd97e1d6d41482b43c0 to your computer and use it in GitHub Desktop.
Save janajri/acd97e1d6d41482b43c0 to your computer and use it in GitHub Desktop.
void httpRequest() {
// We dont want to close the tcp socket
// client.stop();
// if there's a successful connection:
if (client.connect(server, 80)) {
Serial.println("connecting...");
// send the HTTP PUT request:
client.println("GET /latest.txt HTTP/1.1");
client.println("Host: www.arduino.cc");
client.println("User-Agent: ArduinoWiFi/1.1");
//client.println("Connection: close");
client.println("Connection: keep-alive"); // we want to keep the connection alive
client.println();
client.println("GET /latest2.txt HTTP/1.1");
client.println("Host: www.arduino.cc");
client.println("User-Agent: ArduinoWiFi/1.1");
client.println("Connection: keep-alive"); // we want to keep the connection alive
client.println();
// note the time that the connection was made:
lastConnectionTime = millis();
} else {
// if you couldn't make a connection:
Serial.println("connection failed");
}
}
@janajri
Copy link
Author

janajri commented Aug 29, 2015

I'm not sure if the IF statement on line 6 would be necessary. As you can see, I'm attempting to send two http requests right after each other.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment