-->
Page 1 of 1

REMOVING header http reponse

PostPosted: Fri Mar 25, 2016 7:37 am
by borhen
i need to remove htttp reponse this my code in need to print only the time
#include <ESP8266WiFi.h>
#include <SPI.h>

const char WiFiAPPSK[] = "sparkfun";



const char* ssid = "TechMed";
const char* password = "TCM_08@tpeg";

const char* host = "www.timeapi.org"; // Your domain
String path = "/utc/now";
WiFiServer server(80);

void setup()
{

void initHardware();
initHardware();
void setupp ();
setupp ();
delay(10);
Serial.print("Connecting to ");
Serial.println(ssid);

WiFi.begin(ssid, password);
int wifi_ctr = 0;
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}

Serial.println("WiFi connected");
server.begin();
}

void loop()
{

String s = "HTTP/1.1 200 OK\r\n";
s += "Content-Type: text/html\r\n\r\n";
s += "<!DOCTYPE HTML>\r\n<html>\r\n";
Serial.print("connecting to ");
Serial.println(host);
WiFiClient client;
const int httpPort = 80;
if (!client.connect(host, httpPort)) {
Serial.println("connection failed");
return;
}

client.print(String("GET ") + path + " HTTP/1.1\r\n" +
"Host: " + host + "\r\n" +
"Accept-Encoding: gzip,deflate\r\nUser-Agent:ESP8266\r\nContent-Type:application/json\r\n\r\n");

delay(500); // wait for server to respond

// read response
String section="header";

while (client.available()){
String line = client.readStringUntil('\r');

Serial.print(line);
s += "TIME carte = ";
s += String(line)+ " ";

Serial.print("closing connection. ");
}