--- parser3/src/include/pa_http.h 2016/09/01 13:57:04 1.16 +++ parser3/src/include/pa_http.h 2017/02/07 22:00:34 1.19 @@ -1,14 +1,14 @@ /** @file Parser: commonly used functions. - Copyright (c) 2001-2015 Art. Lebedev Studio (http://www.artlebedev.com) + Copyright (c) 2001-2017 Art. Lebedev Studio (http://www.artlebedev.com) Author: Alexandr Petrosian (http://paf.design.ru) */ #ifndef PA_HTTP_H #define PA_HTTP_H -#define IDENT_PA_HTTP_H "$Id: pa_http.h,v 1.16 2016/09/01 13:57:04 moko Exp $" +#define IDENT_PA_HTTP_H "$Id: pa_http.h,v 1.19 2017/02/07 22:00:34 moko Exp $" #include "pa_vstring.h" #include "pa_vint.h" @@ -46,21 +46,16 @@ public: Array
headers; String::Body content_type; + uint64_t content_length; - bool add_header(const char *line){ - const char *value=strchr(line, ':'); + ResponseHeaders() : content_type(""), content_length(0){} - if(value && value != line){ // we need only headers, not the response code - Header header(str_upper(line, value-line), String::Body(value+1).trim(String::TRIM_BOTH, " \t\n\r")); + bool add_header(const char *line); - if(header.name == String::Body(HTTP_CONTENT_TYPE_UPPER) && content_type.is_empty()) - content_type=header.value; - - headers+=header; - - return true; - } - return false; + void clear(){ + headers.clear(); + content_type=""; + content_length=0; } };