Post topics, source code that relate to the Arduino Platform

User avatar
By nigelxx
#45950 I have a NodeMCU - ESP12E DevKit V2 and Arduino IDE.
I can load and run the example sketch "BasicHTTPClient.ino". and read a webpage (or string of csv data in my case)
I am also successfuly passing this data back to another Arduino Mega over serial. This all works fine.

Here is a snippet of the code on the NodeMCU (arduino IDE):

Code: Select allWiFiClient client;
..
..
 client.print(String("GET ") + url + " HTTP/1.1\r\n" +
               "Host: " + host + "\r\n" +
               "Connection: close\r\n\r\n");


The client.print command causes the http header to be written to the serial.

Code: Select allServer: Snorkel/02.03.00.03
Date: Thu, 21 Apr 2016 13:29:04 GMT
Cache-Control: max-age=86400
Expires: Fri, 22 Apr 2016 13:45:05 GMT
Last-Modified: Mon, 22 Feb 201Etag: "56cab79a:0"
Content-Type: text/html;charset=utf-8
Connection: close
Content-Length: 57


Question:
When i request the page with client.print, How can i prevent this header being output to serial?
Is there another client. command i can use?

Thanks for any comments and advise.
User avatar
By martinayotte
#45995 HTTP Header is part of the response. If you wish to throw it away, your code needs to parse the response and find out the location of the first empty line, throwing every thing received before that line and only keeping the following lines.
User avatar
By nigelxx
#46001 Thanks for clarifying that Martin. I had thought of pasring or stripping out the header once it had been received, although this is additional overhead. I just want to read the webpage / csv string. Your suggestion is certainly a workable solution. Thanks again.