void *Parse_parse (int fd, int reqOnly) { http400 = generate400(); //getToken(fd, 1); modify ReqLine_t reqline; Http_t http = 0; if(reqOnly){ reqline = Parse_reqLine (fd); return reqline; } parseHeaders(fd); if (token.kind!=TOKEN_CRLF) parseError(fd); int num = parseBody(fd); reqline = gReqline; http = Http_new (HTTP_KIND_REQUEST , reqline , 0 , 0 , 0); if (DEBUG) Http_print (1, http); return http; }
//////////////////////////////////// // 400 Http_t generate400() { enum HttpKind_t kind = HTTP_KIND_RESPONSE; RespLine_t respLine; Header_t header = 0; char *body; Http_t http = 0; respLine = RespLine_new (HTTP_ONE_ONE , RESP_400 , "bad request"); body = ""; http = Http_new (kind , 0 , respLine , header , body); return http; }
Http_t Parse_parse (int fd) { http400 = generate400(); getToken(fd, 1); ReqLine_t reqline; Http_t http = 0; reqline = parseRequestLine (fd); parseHeaders(fd); if (token.kind!=TOKEN_CRLF) parseError(fd); parseBody(fd); http = Http_new (HTTP_KIND_REQUEST , reqline , 0 , 0 , 0); if (DEBUG) Http_print (1, http); return http; }