static onion_connection_status parse_headers_KEY(onion_request *req, onion_buffer *data){ onion_token *token=req->parser_data; int res=token_read_KEY(token, data); if (res<=1000) return res; ONION_DEBUG0("Got %d at KEY",res); if ( res == NEW_LINE ){ if ((req->flags&OR_METHODS)==OR_POST){ const char *content_type=onion_request_get_header(req, "Content-Type"); if (content_type && (strstr(content_type,"application/x-www-form-urlencoded") || strstr(content_type, "boundary"))) return prepare_POST(req); } if ((req->flags&OR_METHODS)==OR_PUT) return prepare_PUT(req); if (onion_request_get_header(req, "Content-Length")){ // Some length, not POST, get data. int n=atoi(onion_request_get_header(req, "Content-Length")); if (n>0) return prepare_CONTENT_LENGTH(req); } return OCS_REQUEST_READY; } assert(token->extra==NULL); token->extra=onion_low_strdup(token->str); req->parser=parse_headers_VALUE; return parse_headers_VALUE(req, data); }
static onion_connection_status parse_headers_KEY(onion_request *req, onion_buffer *data){ onion_token *token=req->parser_data; int res=token_read_KEY(token, data); if (res<=1000) return res; ONION_DEBUG0("Got %d at KEY",res); if ( res == NEW_LINE ){ #if 0 if ((req->flags&OR_METHODS)==OR_POST) return prepare_POST(req); #endif if ((req->flags&OR_METHODS)==OR_PUT) return prepare_PUT(req); if (onion_request_get_header(req, "Content-Length")){ // Soem length, not POST, get data. int n=atoi(onion_request_get_header(req, "Content-Length")); if (n>0) return prepare_CONTENT_LENGTH(req); } return onion_request_process(req); } token->extra=strdup(token->str); req->parser=parse_headers_VALUE; return parse_headers_VALUE(req, data); }