Fork of the working HTTPClient adaptation using CyaSSL. This version adds a derivation of HTTPText called HTTPJson to emit JSON text properly. Additionally, the URL parser has defines that permit longer URLs to be utilized.
Dependents: SalesforceInterface df-2014-heroku-thermostat-k64f SalesforceInterface
Fork of HTTPClient by
This is a fork of the working HTTPS/SSL library that contains two extensions:
- HTTPJson - a derivation of HTTPText for emitting JSON strings specifically. No JSON parsing/checking is accomplished - HTTPJson simply sets the right Content-Type for HTTP(S).
- Expanded internal buffers for longer URLs. This is set in HTTPClient.cpp and is tunable.
Diff: HTTPClient.cpp
- Revision:
- 31:0675a342e45c
- Parent:
- 30:6fef375c94e6
- Child:
- 32:d9db238bb8a3
diff -r 6fef375c94e6 -r 0675a342e45c HTTPClient.cpp --- a/HTTPClient.cpp Wed Aug 27 21:00:02 2014 +0000 +++ b/HTTPClient.cpp Wed Aug 27 21:19:58 2014 +0000 @@ -331,7 +331,7 @@ send_buf_p = send_buf ; // Reset send buffer ; 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\r\n", meth, path, host); //Write request + snprintf(buf, sizeof(buf), "%s %s HTTP/1.1\r\nHost: %s\r\nConnection: keep-alive\r\n", meth, path, host); //Write request ret = send(buf); if(ret) { m_sock.close(); @@ -343,8 +343,8 @@ //Send default headers DBG("Sending headers"); - if(m_basicAuthUser) { - bAuth() ; /* send out Basic Auth header */ + if(m_basicAuthUser && m_basicAuthPassword) { + bAuth() ; /* send out Basic Auth header */ } if( pDataOut != NULL ) { if( pDataOut->getIsChunked() ) { @@ -509,7 +509,7 @@ } else if( !strcmp(key, "Content-Type") ) { pDataIn->setDataType(value); } else if( !strcmp(key, "location") && redirect_url) { - sscanf(buf, "%31[^:]: %128[^\r\n]", key, redirect_url); + sscanf(buf, "%40[^:]: %128[^\r\n]", key, redirect_url); DBG("Redirect %s: %s", key, redirect_url) ; redirect = 1 ; }