From e7b86baeec0ef6f946e2b60a68876eb6f3cdc32e Mon Sep 17 00:00:00 2001 From: Wolfgang Draxinger Date: Tue, 18 Jun 2013 22:14:52 +0200 Subject: ... --- picohttp.c | 7 +++++++ picohttp.h | 4 +--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/picohttp.c b/picohttp.c index 43d4652..eb5decc 100644 --- a/picohttp.c +++ b/picohttp.c @@ -196,6 +196,13 @@ static int16_t picohttpIoGetPercentCh( return ch; } +uint16_t picohttpGetch(struct picohttpRequest * const req) +{ + /* read HTTP query body, skipping over Chunked Transfer Boundaries + * if Chunked Transfer Encoding is used */ + +} + /* TODO: * It is possible to do in-place pattern matching on the route definition * array, without first reading in the URL and then processing it here. diff --git a/picohttp.h b/picohttp.h index 803587d..24212e5 100644 --- a/picohttp.h +++ b/picohttp.h @@ -138,9 +138,7 @@ int picohttpResponseWrite ( size_t len, char const *buf ); -uint16_t picohttpGetch( - struct picohttpRequest * const req, - struct picohttpChunkTransfer * const ct); +uint16_t picohttpGetch(struct picohttpRequest * const req); int picohttpMultipartNext( struct picohttpRequest * const req, -- cgit v1.2.3 From 21ac350ef7d59e88dd0ee725cdd94edbfdfcb7d6 Mon Sep 17 00:00:00 2001 From: Wolfgang Draxinger Date: Thu, 20 Jun 2013 16:07:59 +0200 Subject: multipart getchar --- picohttp.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/picohttp.c b/picohttp.c index ff5a4dc..1304a2f 100644 --- a/picohttp.c +++ b/picohttp.c @@ -885,3 +885,47 @@ int picohttpResponseWrite ( return len; } +uint16_t picohttpMultipartGetch( + struct picohttpMultiPart * const mp); +{ + if( mp->replay + mp->in_boundary < 0) { + uint16_t ch = mp->replay < 1 ? '-' : + mp->req->query.multipartboundary[mp->replay - 1]; + mp->replay++; + return ch; + } else if( mp->finished) { + return -1; + } else { + uint16_t ch; + ch = picohttpIoGetch(mp->req->ioops); + if( 0 > ch ) { + return ch; + } + + if( (0 == mp->in_boundary && '\r' == ch) || + (1 == mp->in_boundary && '\n' == ch) || + (2 < mp->in_boundary && '-' == ch) || + (4 < mp->in_boundary && + mp->req->query.multipartboundary[mp->in_boundary-4] == ch) ) { + if( 5 < mp->in_boundary && + 0 == mp->req->query.multipartboundary[mp->in_boundary-3] ) { + /* matched boundary */ + mp->finished = 1; + return 0; + } + mp->in_boundary++; + ch = picohttpIoGetch(mp->req->ioops); + if( 0 >= ch ) { + return -1; + } + } else { + mp->replay = mp->in_boundary + 1; + return '-'; + } + } +} + + + + + -- cgit v1.2.3