diff --git a/src/ArduinoHttpClient.h b/src/ArduinoHttpClient.h index abb8494..578733f 100644 --- a/src/ArduinoHttpClient.h +++ b/src/ArduinoHttpClient.h @@ -7,6 +7,5 @@ #include "HttpClient.h" #include "WebSocketClient.h" -#include "URLEncoder.h" #endif diff --git a/src/HttpClient.cpp b/src/HttpClient.cpp index 7517eea..eef4054 100644 --- a/src/HttpClient.cpp +++ b/src/HttpClient.cpp @@ -64,7 +64,7 @@ void HttpClient::beginRequest() } int HttpClient::startRequest(const char* aURLPath, const char* aHttpMethod, - const char* aContentType, int aContentLength, const byte aBody[]) + const char* aContentType, long aContentLength, const byte aBody[]) { if (iState == eReadingBody || iState == eReadingChunkLength || iState == eReadingBodyChunk) { @@ -311,7 +311,7 @@ int HttpClient::post(const String& aURLPath, const String& aContentType, const S return post(aURLPath.c_str(), aContentType.c_str(), aBody.length(), (const byte*)aBody.c_str()); } -int HttpClient::post(const char* aURLPath, const char* aContentType, int aContentLength, const byte aBody[]) +int HttpClient::post(const char* aURLPath, const char* aContentType, long aContentLength, const byte aBody[]) { return startRequest(aURLPath, HTTP_METHOD_POST, aContentType, aContentLength, aBody); } @@ -336,7 +336,7 @@ int HttpClient::put(const String& aURLPath, const String& aContentType, const St return put(aURLPath.c_str(), aContentType.c_str(), aBody.length(), (const byte*)aBody.c_str()); } -int HttpClient::put(const char* aURLPath, const char* aContentType, int aContentLength, const byte aBody[]) +int HttpClient::put(const char* aURLPath, const char* aContentType, long aContentLength, const byte aBody[]) { return startRequest(aURLPath, HTTP_METHOD_PUT, aContentType, aContentLength, aBody); } @@ -361,7 +361,7 @@ int HttpClient::patch(const String& aURLPath, const String& aContentType, const return patch(aURLPath.c_str(), aContentType.c_str(), aBody.length(), (const byte*)aBody.c_str()); } -int HttpClient::patch(const char* aURLPath, const char* aContentType, int aContentLength, const byte aBody[]) +int HttpClient::patch(const char* aURLPath, const char* aContentType, long aContentLength, const byte aBody[]) { return startRequest(aURLPath, HTTP_METHOD_PATCH, aContentType, aContentLength, aBody); } @@ -386,7 +386,7 @@ int HttpClient::del(const String& aURLPath, const String& aContentType, const St return del(aURLPath.c_str(), aContentType.c_str(), aBody.length(), (const byte*)aBody.c_str()); } -int HttpClient::del(const char* aURLPath, const char* aContentType, int aContentLength, const byte aBody[]) +int HttpClient::del(const char* aURLPath, const char* aContentType, long aContentLength, const byte aBody[]) { return startRequest(aURLPath, HTTP_METHOD_DELETE, aContentType, aContentLength, aBody); } @@ -542,7 +542,7 @@ bool HttpClient::endOfHeadersReached() return (iState == eReadingBody || iState == eReadingChunkLength || iState == eReadingBodyChunk); }; -int HttpClient::contentLength() +long HttpClient::contentLength() { // skip the response headers, if they haven't been read already if (!endOfHeadersReached()) @@ -555,7 +555,7 @@ int HttpClient::contentLength() String HttpClient::responseBody() { - int bodyLength = contentLength(); + long bodyLength = contentLength(); String response; if (bodyLength > 0) @@ -586,7 +586,7 @@ String HttpClient::responseBody() } } - if (bodyLength > 0 && (unsigned int)bodyLength != response.length()) { + if (bodyLength > 0 && (long)bodyLength != response.length()) { // failure, we did not read in reponse content length bytes return String((const char*)NULL); } diff --git a/src/HttpClient.h b/src/HttpClient.h index 38fd799..ac16574 100644 --- a/src/HttpClient.h +++ b/src/HttpClient.h @@ -94,7 +94,7 @@ class HttpClient : public Client */ int post(const char* aURLPath, const char* aContentType, const char* aBody); int post(const String& aURLPath, const String& aContentType, const String& aBody); - int post(const char* aURLPath, const char* aContentType, int aContentLength, const byte aBody[]); + int post(const char* aURLPath, const char* aContentType, long aContentLength, const byte aBody[]); /** Connect to the server and start to send a PUT request. @param aURLPath Url to request @@ -112,7 +112,7 @@ class HttpClient : public Client */ int put(const char* aURLPath, const char* aContentType, const char* aBody); int put(const String& aURLPath, const String& aContentType, const String& aBody); - int put(const char* aURLPath, const char* aContentType, int aContentLength, const byte aBody[]); + int put(const char* aURLPath, const char* aContentType, long aContentLength, const byte aBody[]); /** Connect to the server and start to send a PATCH request. @param aURLPath Url to request @@ -130,7 +130,7 @@ class HttpClient : public Client */ int patch(const char* aURLPath, const char* aContentType, const char* aBody); int patch(const String& aURLPath, const String& aContentType, const String& aBody); - int patch(const char* aURLPath, const char* aContentType, int aContentLength, const byte aBody[]); + int patch(const char* aURLPath, const char* aContentType, long aContentLength, const byte aBody[]); /** Connect to the server and start to send a DELETE request. @param aURLPath Url to request @@ -148,7 +148,7 @@ class HttpClient : public Client */ int del(const char* aURLPath, const char* aContentType, const char* aBody); int del(const String& aURLPath, const String& aContentType, const String& aBody); - int del(const char* aURLPath, const char* aContentType, int aContentLength, const byte aBody[]); + int del(const char* aURLPath, const char* aContentType, long aContentLength, const byte aBody[]); /** Connect to the server and start to send the request. If a body is provided, the entire request (including headers and body) will be sent @@ -162,13 +162,13 @@ class HttpClient : public Client int startRequest(const char* aURLPath, const char* aHttpMethod, const char* aContentType = NULL, - int aContentLength = -1, + long aContentLength = -1, const byte aBody[] = NULL); /** Send an additional header line. This can only be called in between the - calls to beginRequest and endRequest. + calls to startRequest and finishRequest. @param aHeader Header line to send, in its entirety (but without the - trailing CRLF. E.g. "Authorization: Basic YQDDCAIGES" + trailing CRLF. E.g. "Authorization: Basic YQDDCAIGES" */ void sendHeader(const char* aHeader); @@ -272,7 +272,7 @@ class HttpClient : public Client @return Length of the body, in bytes, or kNoContentLengthHeader if no Content-Length header was returned by the server */ - int contentLength(); + long contentLength(); /** Returns if the response body is chunked @return true if response body is chunked, false otherwise @@ -307,7 +307,7 @@ class HttpClient : public Client virtual int read(); virtual int read(uint8_t *buf, size_t size); virtual int peek() { return iClient->peek(); }; - virtual void flush() { iClient->flush(); }; + virtual void flush() { return iClient->flush(); }; // Inherited from Client virtual int connect(IPAddress ip, uint16_t port) { return iClient->connect(ip, port); }; @@ -372,9 +372,9 @@ class HttpClient : public Client // Stores the status code for the response, once known int iStatusCode; // Stores the value of the Content-Length header, if present - int iContentLength; + long iContentLength; // How many bytes of the response body have been read by the user - int iBodyLengthConsumed; + long iBodyLengthConsumed; // How far through a Content-Length header prefix we are const char* iContentLengthPtr; // How far through a Transfer-Encoding chunked header we are