Skip to content

Commit 85c47db

Browse files
giving access to the HTTP return code
1 parent 70a94e8 commit 85c47db

2 files changed

Lines changed: 12 additions & 4 deletions

File tree

‎HTTPClient.cpp‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ sendUriAndHeaders(FILE* stream, char* hostName, char* requestType, char* uri,
3434
uri_parameter parameters[], char* headers);
3535
char
3636
sendContentPayload(FILE* stream, char* data);
37-
char
37+
int
3838
skipHeader(FILE* stream);
3939

4040
//a struct to store the uriEncoder & the handle to the http client
@@ -143,6 +143,11 @@ HTTPClient::putURI(char* uri, uri_parameter parameters[], char* data,
143143
return result;
144144
}
145145

146+
int HTTPClient::getLastReturnCode(void)
147+
{
148+
return lastReturnCode;
149+
}
150+
146151
void
147152
HTTPClient::setEncoding(FILE* stream, char encode, char encodeReserved)
148153
{
@@ -362,13 +367,12 @@ HTTPClient::clientRead(FILE* stream)
362367
}
363368
}
364369

365-
char
370+
int
366371
skipHeader(FILE* stream)
367372
{
368373
//skip over the header
369-
int return_code = 0;
370374
fscanf_P(stream, PSTR("HTTP/1.1 %i"), &return_code);
371-
Serial.println(return_code);
375+
Serial.println(lastReturnCode);
372376
static int inByte = 0;
373377
static int lastByte = 0;
374378
while (!(inByte == '\n' && lastByte == '\n'))

‎HTTPClient.h‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ class HTTPClient: private Client {
3939
private:
4040
char* hostName;
4141
uint8_t hostIp;
42+
int lastReturnCode;
43+
4244
//opening the client stream
4345
FILE* openClientFile();
4446
//the rw routines
@@ -59,6 +61,8 @@ class HTTPClient: private Client {
5961
FILE* putURI(char* uri, uri_parameter parameters[],char* data);
6062
FILE* putURI(char* uri, uri_parameter parameters[],char* data, char* headers);
6163

64+
int getLastReturnCode(void);
65+
6266
static void setEncoding(FILE* stream, char encode, char encodeReserved);
6367
static void closeStream(FILE* stream);
6468
};

0 commit comments

Comments
 (0)