From 9fec30ee4e98dee6411280547d861a30c76c626a Mon Sep 17 00:00:00 2001 From: Wolfgang Draxinger Date: Thu, 18 Jul 2013 18:44:37 +0200 Subject: start of branch --- picohttp.c | 21 ++++++++++++++++++++- test/bsdsocket.c | 4 ++-- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/picohttp.c b/picohttp.c index 810fe1b..9b28b92 100644 --- a/picohttp.c +++ b/picohttp.c @@ -1124,11 +1124,13 @@ int picohttpMultipartGetch( if( mp->replayhead < mp->replay ) { ch = mp->req->query.multipartboundary[mp->replayhead]; mp->replayhead++; + debug_printf("replay head: %0.2x\n", ch); return ch; } else { ch = mp->req->query.prev_ch[0]; mp->replay = 0; mp->replayhead = 0; + debug_printf("replay prev: %0.2x\n", ch); return ch; } } else { @@ -1143,16 +1145,29 @@ int picohttpMultipartGetch( * a sequence. */ + switch(ch) { + case '\r': + debug_printf("(CR)", ch); break; + case '\n': + debug_printf("(LF)", ch); break; + default: + debug_printf("(%c)", ch); + } if( '\r' == ch ) { mp->replayhead = mp->in_boundary = 0; - if( '\r' == mp->req->query.prev_ch[1] ) + if( '\r' == mp->req->query.prev_ch[1] ) { + debug_printf(""); return '\r'; + } else { + debug_printf(""); + } } else if( '\n' == ch && '\r' == mp->req->query.prev_ch[1] ) { mp->replayhead = mp->in_boundary = 1; + debug_printf(""); } else if( '-' == ch && '\n' == mp->req->query.prev_ch[1] && @@ -1160,12 +1175,14 @@ int picohttpMultipartGetch( ) { mp->replayhead = mp->in_boundary = 2; + debug_printf("-"); } while( 0 <= ch ) { if( mp->req->query.multipartboundary[mp->in_boundary] == ch ) { if( 0 == mp->req->query.multipartboundary[mp->in_boundary+1] ) { + debug_printf("{|}", ch); mp->in_boundary = 0; mp->replay = 0; /* matched boundary */ @@ -1188,8 +1205,10 @@ int picohttpMultipartGetch( return -1; } + debug_printf("{#}", ch); mp->in_boundary++; } else { + debug_printf("{_}", ch); if( mp->in_boundary ) { /* In case the mismatch was due to a or diff --git a/test/bsdsocket.c b/test/bsdsocket.c index cb06d58..1d5f8d5 100644 --- a/test/bsdsocket.c +++ b/test/bsdsocket.c @@ -151,9 +151,9 @@ void rhUpload(struct picohttpRequest *req) ch = picohttpMultipartGetch(&mp) ) { switch(ch) { case '\r': - fputs("--- ---\n", stderr); break; + fputs("[CR]", stderr); break; case '\n': - fputs("--- ---\n", stderr); break; + fputs("[LF]", stderr); break; default: fputc(ch, stderr); -- cgit v1.2.3