net: http: add numeric http status code to response struct
Add numeric http status code to the response struct to allow for easier processing by the caller. Textual status already exists. Signed-off-by: Justin Morton <justin.morton@nordicsemi.no>
This commit is contained in:
parent
4289e46ae7
commit
35f598ba93
2 changed files with 7 additions and 0 deletions
|
@ -146,6 +146,11 @@ struct http_response {
|
||||||
*/
|
*/
|
||||||
char http_status[HTTP_STATUS_STR_SIZE];
|
char http_status[HTTP_STATUS_STR_SIZE];
|
||||||
|
|
||||||
|
/** Numeric HTTP status code which corresponds to the
|
||||||
|
* textual description.
|
||||||
|
*/
|
||||||
|
uint16_t http_status_code;
|
||||||
|
|
||||||
uint8_t cl_present : 1;
|
uint8_t cl_present : 1;
|
||||||
uint8_t body_found : 1;
|
uint8_t body_found : 1;
|
||||||
uint8_t message_complete : 1;
|
uint8_t message_complete : 1;
|
||||||
|
|
|
@ -176,6 +176,8 @@ static int on_status(struct http_parser *parser, const char *at, size_t length)
|
||||||
if (req->internal.response.http_cb &&
|
if (req->internal.response.http_cb &&
|
||||||
req->internal.response.http_cb->on_status) {
|
req->internal.response.http_cb->on_status) {
|
||||||
req->internal.response.http_cb->on_status(parser, at, length);
|
req->internal.response.http_cb->on_status(parser, at, length);
|
||||||
|
req->internal.response.http_status_code =
|
||||||
|
(uint16_t)parser->status_code;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue