Changed key and value max length from 32 to 64 to accommodate for longer header lines.
Fork of HTTPClient by
Diff: HTTPClient.cpp
- Revision:
- 19:e5a52252710f
- Parent:
- 18:277279a1891e
- Child:
- 20:89ad63c03f10
--- a/HTTPClient.cpp Wed May 07 16:48:10 2014 +0000 +++ b/HTTPClient.cpp Wed Nov 19 20:56:47 2014 +0000 @@ -18,7 +18,7 @@ */ //Debug is disabled by default -#if 0 +#if 1 //Enable debug #include <cstdio> #define DBG(x, ...) std::printf("[HTTPClient : DBG]"x"\r\n", ##__VA_ARGS__); @@ -42,6 +42,9 @@ #define CHUNK_SIZE 256 +#define KEY_MAX_SIZE 64 +#define VAL_MAX_SIZE 64 + #include <cstring> #include "HTTPClient.h" @@ -175,6 +178,7 @@ DBG("Sending headers"); if( pDataOut != NULL ) { + DBG("found pDataOut"); if( pDataOut->getIsChunked() ) { ret = send("Transfer-Encoding: chunked\r\n"); @@ -205,8 +209,10 @@ } //Send specific headers + int i = 1; while( pDataIn->getHeader(buf, sizeof(buf) - 3) ) { + DBG("Sending specific headers pass %d", i++); size_t headerlen = strlen(buf); snprintf(buf + headerlen, sizeof(buf) - headerlen, "\r\n"); ret = send(buf); @@ -364,14 +370,14 @@ buf[crlfPos] = '\0'; - char key[32]; - char value[32]; + char key[KEY_MAX_SIZE]; + char value[VAL_MAX_SIZE]; //key[31] = '\0'; //value[31] = '\0'; - memset(key, 0, 32); - memset(value, 0, 32); + memset(key, 0, KEY_MAX_SIZE); + memset(value, 0, VAL_MAX_SIZE); //int n = sscanf(buf, "%31[^:]: %31[^\r\n]", key, value); @@ -381,14 +387,14 @@ if(keyEnd != NULL) { *keyEnd = '\0'; - if(strlen(buf) < 32) + if(strlen(buf) < KEY_MAX_SIZE) { strcpy(key, buf); n++; char* valueStart = keyEnd + 2; if( (valueStart - buf) < crlfPos ) { - if(strlen(valueStart) < 32) + if(strlen(valueStart) < VAL_MAX_SIZE) { strcpy(value, valueStart); n++;