mirror of
https://github.com/logicog/RTLPlayground.git
synced 2026-09-02 15:02:51 +08:00
httpd: parse Content-Length in scan_header()
Record the announced body length alongside Content-Type and the session cookie. The value goes through parse_short(), so an announcement that does not fit sixteen bits saturates at 0xffff rather than wrapping to something the size checks would accept, and a missing or unparseable header reads as 0. Nothing consumes it yet; the plain POST endpoints take it up next.
This commit is contained in:
+6
-1
@@ -54,6 +54,7 @@ __xdata uint8_t config_buf[CONFIG_UPLOAD_BUF];
|
|||||||
__xdata uint16_t pre_acc;
|
__xdata uint16_t pre_acc;
|
||||||
__xdata uint8_t * __xdata content_type = 0;
|
__xdata uint8_t * __xdata content_type = 0;
|
||||||
__xdata uint8_t * __xdata session = 0;
|
__xdata uint8_t * __xdata session = 0;
|
||||||
|
__xdata uint16_t content_length;
|
||||||
|
|
||||||
// Global variables holding POST state
|
// Global variables holding POST state
|
||||||
__xdata uint16_t bindex; // Current index into the boundary
|
__xdata uint16_t bindex; // Current index into the boundary
|
||||||
@@ -272,6 +273,7 @@ __xdata uint8_t *scan_header(__xdata uint8_t * __xdata p)
|
|||||||
__xdata uint8_t *v;
|
__xdata uint8_t *v;
|
||||||
|
|
||||||
content_type = 0;
|
content_type = 0;
|
||||||
|
content_length = 0;
|
||||||
session = 0;
|
session = 0;
|
||||||
authenticated = 0;
|
authenticated = 0;
|
||||||
|
|
||||||
@@ -282,7 +284,10 @@ __xdata uint8_t *scan_header(__xdata uint8_t * __xdata p)
|
|||||||
p++;
|
p++;
|
||||||
if ((v = header_value(p, "\ncontent-type:")))
|
if ((v = header_value(p, "\ncontent-type:")))
|
||||||
content_type = v;
|
content_type = v;
|
||||||
else if ((v = header_value(p, "\ncookie:"))) {
|
else if ((v = header_value(p, "\ncontent-length:"))) {
|
||||||
|
parse_short(v);
|
||||||
|
content_length = short_parsed;
|
||||||
|
} else if ((v = header_value(p, "\ncookie:"))) {
|
||||||
/* Scan for the "session" key: the header may hold several
|
/* Scan for the "session" key: the header may hold several
|
||||||
* cookies in any order. Match "session" not "session=" -
|
* cookies in any order. Match "session" not "session=" -
|
||||||
* is_word() requires a separator after the match and '=' is
|
* is_word() requires a separator after the match and '=' is
|
||||||
|
|||||||
Reference in New Issue
Block a user