-->
Page 1 of 1

WifiClient - Prevent serial output

PostPosted: Thu Apr 21, 2016 2:55 pm
by nigelxx
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.

Re: WifiClient - Prevent serial output

PostPosted: Fri Apr 22, 2016 9:39 am
by martinayotte
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.

Re: WifiClient - Prevent serial output

PostPosted: Fri Apr 22, 2016 11:02 am
by nigelxx
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.