Skip to content

Commit 7931767

Browse files
author
Tomaz
committed
from previous lib
1 parent 7f36561 commit 7931767

File tree

3 files changed

+19
-20
lines changed

3 files changed

+19
-20
lines changed

src/ArduinoHttpClient.h

-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,5 @@
77

88
#include "HttpClient.h"
99
#include "WebSocketClient.h"
10-
#include "URLEncoder.h"
1110

1211
#endif

src/HttpClient.cpp

+8-8
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ void HttpClient::beginRequest()
6464
}
6565

6666
int HttpClient::startRequest(const char* aURLPath, const char* aHttpMethod,
67-
const char* aContentType, int aContentLength, const byte aBody[])
67+
const char* aContentType, long aContentLength, const byte aBody[])
6868
{
6969
if (iState == eReadingBody || iState == eReadingChunkLength || iState == eReadingBodyChunk)
7070
{
@@ -311,7 +311,7 @@ int HttpClient::post(const String& aURLPath, const String& aContentType, const S
311311
return post(aURLPath.c_str(), aContentType.c_str(), aBody.length(), (const byte*)aBody.c_str());
312312
}
313313

314-
int HttpClient::post(const char* aURLPath, const char* aContentType, int aContentLength, const byte aBody[])
314+
int HttpClient::post(const char* aURLPath, const char* aContentType, long aContentLength, const byte aBody[])
315315
{
316316
return startRequest(aURLPath, HTTP_METHOD_POST, aContentType, aContentLength, aBody);
317317
}
@@ -336,7 +336,7 @@ int HttpClient::put(const String& aURLPath, const String& aContentType, const St
336336
return put(aURLPath.c_str(), aContentType.c_str(), aBody.length(), (const byte*)aBody.c_str());
337337
}
338338

339-
int HttpClient::put(const char* aURLPath, const char* aContentType, int aContentLength, const byte aBody[])
339+
int HttpClient::put(const char* aURLPath, const char* aContentType, long aContentLength, const byte aBody[])
340340
{
341341
return startRequest(aURLPath, HTTP_METHOD_PUT, aContentType, aContentLength, aBody);
342342
}
@@ -361,7 +361,7 @@ int HttpClient::patch(const String& aURLPath, const String& aContentType, const
361361
return patch(aURLPath.c_str(), aContentType.c_str(), aBody.length(), (const byte*)aBody.c_str());
362362
}
363363

364-
int HttpClient::patch(const char* aURLPath, const char* aContentType, int aContentLength, const byte aBody[])
364+
int HttpClient::patch(const char* aURLPath, const char* aContentType, long aContentLength, const byte aBody[])
365365
{
366366
return startRequest(aURLPath, HTTP_METHOD_PATCH, aContentType, aContentLength, aBody);
367367
}
@@ -386,7 +386,7 @@ int HttpClient::del(const String& aURLPath, const String& aContentType, const St
386386
return del(aURLPath.c_str(), aContentType.c_str(), aBody.length(), (const byte*)aBody.c_str());
387387
}
388388

389-
int HttpClient::del(const char* aURLPath, const char* aContentType, int aContentLength, const byte aBody[])
389+
int HttpClient::del(const char* aURLPath, const char* aContentType, long aContentLength, const byte aBody[])
390390
{
391391
return startRequest(aURLPath, HTTP_METHOD_DELETE, aContentType, aContentLength, aBody);
392392
}
@@ -542,7 +542,7 @@ bool HttpClient::endOfHeadersReached()
542542
return (iState == eReadingBody || iState == eReadingChunkLength || iState == eReadingBodyChunk);
543543
};
544544

545-
int HttpClient::contentLength()
545+
long HttpClient::contentLength()
546546
{
547547
// skip the response headers, if they haven't been read already
548548
if (!endOfHeadersReached())
@@ -555,7 +555,7 @@ int HttpClient::contentLength()
555555

556556
String HttpClient::responseBody()
557557
{
558-
int bodyLength = contentLength();
558+
long bodyLength = contentLength();
559559
String response;
560560

561561
if (bodyLength > 0)
@@ -586,7 +586,7 @@ String HttpClient::responseBody()
586586
}
587587
}
588588

589-
if (bodyLength > 0 && (unsigned int)bodyLength != response.length()) {
589+
if (bodyLength > 0 && (long)bodyLength != response.length()) {
590590
// failure, we did not read in reponse content length bytes
591591
return String((const char*)NULL);
592592
}

src/HttpClient.h

+11-11
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ class HttpClient : public Client
9494
*/
9595
int post(const char* aURLPath, const char* aContentType, const char* aBody);
9696
int post(const String& aURLPath, const String& aContentType, const String& aBody);
97-
int post(const char* aURLPath, const char* aContentType, int aContentLength, const byte aBody[]);
97+
int post(const char* aURLPath, const char* aContentType, long aContentLength, const byte aBody[]);
9898

9999
/** Connect to the server and start to send a PUT request.
100100
@param aURLPath Url to request
@@ -112,7 +112,7 @@ class HttpClient : public Client
112112
*/
113113
int put(const char* aURLPath, const char* aContentType, const char* aBody);
114114
int put(const String& aURLPath, const String& aContentType, const String& aBody);
115-
int put(const char* aURLPath, const char* aContentType, int aContentLength, const byte aBody[]);
115+
int put(const char* aURLPath, const char* aContentType, long aContentLength, const byte aBody[]);
116116

117117
/** Connect to the server and start to send a PATCH request.
118118
@param aURLPath Url to request
@@ -130,7 +130,7 @@ class HttpClient : public Client
130130
*/
131131
int patch(const char* aURLPath, const char* aContentType, const char* aBody);
132132
int patch(const String& aURLPath, const String& aContentType, const String& aBody);
133-
int patch(const char* aURLPath, const char* aContentType, int aContentLength, const byte aBody[]);
133+
int patch(const char* aURLPath, const char* aContentType, long aContentLength, const byte aBody[]);
134134

135135
/** Connect to the server and start to send a DELETE request.
136136
@param aURLPath Url to request
@@ -148,7 +148,7 @@ class HttpClient : public Client
148148
*/
149149
int del(const char* aURLPath, const char* aContentType, const char* aBody);
150150
int del(const String& aURLPath, const String& aContentType, const String& aBody);
151-
int del(const char* aURLPath, const char* aContentType, int aContentLength, const byte aBody[]);
151+
int del(const char* aURLPath, const char* aContentType, long aContentLength, const byte aBody[]);
152152

153153
/** Connect to the server and start to send the request.
154154
If a body is provided, the entire request (including headers and body) will be sent
@@ -162,13 +162,13 @@ class HttpClient : public Client
162162
int startRequest(const char* aURLPath,
163163
const char* aHttpMethod,
164164
const char* aContentType = NULL,
165-
int aContentLength = -1,
165+
long aContentLength = -1,
166166
const byte aBody[] = NULL);
167167

168168
/** Send an additional header line. This can only be called in between the
169-
calls to beginRequest and endRequest.
169+
calls to startRequest and finishRequest.
170170
@param aHeader Header line to send, in its entirety (but without the
171-
trailing CRLF. E.g. "Authorization: Basic YQDDCAIGES"
171+
trailing CRLF. E.g. "Authorization: Basic YQDDCAIGES"
172172
*/
173173
void sendHeader(const char* aHeader);
174174

@@ -272,7 +272,7 @@ class HttpClient : public Client
272272
@return Length of the body, in bytes, or kNoContentLengthHeader if no
273273
Content-Length header was returned by the server
274274
*/
275-
int contentLength();
275+
long contentLength();
276276

277277
/** Returns if the response body is chunked
278278
@return true if response body is chunked, false otherwise
@@ -307,7 +307,7 @@ class HttpClient : public Client
307307
virtual int read();
308308
virtual int read(uint8_t *buf, size_t size);
309309
virtual int peek() { return iClient->peek(); };
310-
virtual void flush() { iClient->flush(); };
310+
virtual void flush() { return iClient->flush(); };
311311

312312
// Inherited from Client
313313
virtual int connect(IPAddress ip, uint16_t port) { return iClient->connect(ip, port); };
@@ -372,9 +372,9 @@ class HttpClient : public Client
372372
// Stores the status code for the response, once known
373373
int iStatusCode;
374374
// Stores the value of the Content-Length header, if present
375-
int iContentLength;
375+
long iContentLength;
376376
// How many bytes of the response body have been read by the user
377-
int iBodyLengthConsumed;
377+
long iBodyLengthConsumed;
378378
// How far through a Content-Length header prefix we are
379379
const char* iContentLengthPtr;
380380
// How far through a Transfer-Encoding chunked header we are

0 commit comments

Comments
 (0)