Hello everyone,
I've been using the HTTPClient library with success, but I'm having difficulty with the getResponseHeader() member function. It appears to always return an empty string, no matter what header key you specify. I confirm that the accessed website is returning a response with the headers I'm expecting. This is done using Firefox Web Developer Web console. So either I am not using the member function correctly, or there is a bug within HTTPClient.
The API documentation is a little sparse to know if I am using it correctly - it reads:
Quote:
string& getResponseHeader(const string &header)
Gets a response header.
Yes, to the point! But what exactly do you pass to the function? I assume it is the HTML response header name.
Unfortunately, I cannot access the C++ class source to investigate further. The author has only published the header. So it is difficult to know if what I've done is reasonable effort.
[25/10/2011 - I have since learnt that you can edit imported libraries, and here you may reveal the source if the author has published them]
Here is the code:
#include "mbed.h"
#include "HTTPClient.h"
HTTPClient myClient;
HTTPResult myResult;
HTTPText myText("text/html", 640);
int myRespCode;
string myRespHeader;
string myUrl = "http://www.somewebsite.com";
myText.set("<some legal HTML />");
myResult = myClient.post(myUrl.c_str(), myText, NULL);
myRespCode = myClient.getHTTPResponseCode();
myRespHeader = myClient.getResponseHeader("Date"); // <-- Is this correct?
Then I print it out to see what I've got:
<stuff to instantiate an LCD>
lcd.printf("R:'%s'", myRespHeader.c_str());
If this is a C++ coding error on my part, please shout! If you've used it, do share!
Hello everyone,
I've been using the HTTPClient library with success, but I'm having difficulty with the getResponseHeader() member function. It appears to always return an empty string, no matter what header key you specify. I confirm that the accessed website is returning a response with the headers I'm expecting. This is done using Firefox Web Developer Web console. So either I am not using the member function correctly, or there is a bug within HTTPClient.
The API documentation is a little sparse to know if I am using it correctly - it reads:
Quote:
string& getResponseHeader(const string &header)
Gets a response header.
Yes, to the point! But what exactly do you pass to the function? I assume it is the HTML response header name.
Unfortunately, I cannot access the C++ class source to investigate further. The author has only published the header. So it is difficult to know if what I've done is reasonable effort.
[25/10/2011 - I have since learnt that you can edit imported libraries, and here you may reveal the source if the author has published them]
Here is the code:
Then I print it out to see what I've got:
If this is a C++ coding error on my part, please shout! If you've used it, do share!