Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: Sample_HTTPClient Sample_HTTPClient LWM2M_NanoService_Ethernet LWM2M_NanoService_Ethernet ... more
Fork of HTTPClient by
More recent changes - added iCal processing.
Derivative of a derivative, however this one works when it comes to supplying Basic authorization to access a protected resource. Some additional changes to the debug interface to clean it up for consistency with many other components I have.
Revision 31:96da7c08b5d0, committed 2014-07-26
- Comitter:
- WiredHome
- Date:
- Sat Jul 26 19:47:36 2014 +0000
- Parent:
- 30:1df62fedb13b
- Child:
- 32:7b9919d59194
- Commit message:
- Increase a couple of buffers in order to post a long query string to a web site.
Changed in this revision
| HTTPClient.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/HTTPClient.cpp Sat Jul 05 22:26:07 2014 +0000
+++ b/HTTPClient.cpp Sat Jul 26 19:47:36 2014 +0000
@@ -40,6 +40,7 @@
#define MAX(x,y) (((x)>(y))?(x):(y))
#define CHUNK_SIZE 256
+#define MAXLEN_VALUE 120 /* Max URL and Max Value for Name:Value */
#include <cstring>
@@ -150,7 +151,7 @@
char scheme[8];
uint16_t port;
char host[32];
- char path[64];
+ char path[MAXLEN_VALUE];
size_t recvContentLength = 0;
bool recvChunked = false;
int crlfPos = 0;
@@ -193,6 +194,7 @@
DBG("Sending request");
const char* meth = (method==HTTP_GET)?"GET":(method==HTTP_POST)?"POST":(method==HTTP_PUT)?"PUT":(method==HTTP_DELETE)?"DELETE":"";
snprintf(buf, sizeof(buf), "%s %s HTTP/1.1\r\nHost: %s:%d\r\nConnection: keep-alive\r\n", meth, path, host, port); //Write request
+ INFO(" buf{%s}", buf);
ret = send(buf);
if (ret) {
m_sock.close();
@@ -359,12 +361,12 @@
buf[crlfPos] = '\0';
char key[32];
- char value[64];
+ char value[MAXLEN_VALUE];
key[31] = '\0';
- value[63] = '\0';
+ value[MAXLEN_VALUE - 1] = '\0';
- int n = sscanf(buf, "%31[^:]: %63[^\r\n]", key, value);
+ int n = sscanf(buf, "%31[^:]: %160[^\r\n]", key, value);
if ( n == 2 ) {
DBG("Read header : %s: %s", key, value);
if( !strcmp(key, "Content-Length") ) {
