Annotation of parser3/src/include/pa_http.h, revision 1.16
1.1 paf 1: /** @file
2: Parser: commonly used functions.
3:
1.14 moko 4: Copyright (c) 2001-2015 Art. Lebedev Studio (http://www.artlebedev.com)
1.1 paf 5: Author: Alexandr Petrosian <paf@design.ru> (http://paf.design.ru)
6: */
7:
8: #ifndef PA_HTTP_H
9: #define PA_HTTP_H
10:
1.16 ! moko 11: #define IDENT_PA_HTTP_H "$Id: pa_http.h,v 1.15 2016/07/26 13:20:23 moko Exp $"
1.1 paf 12:
13: #include "pa_vstring.h"
14: #include "pa_vint.h"
15: #include "pa_vhash.h"
16: #include "pa_vtable.h"
17: #include "pa_socks.h"
1.15 moko 18: #include "pa_charset.h"
1.10 misha 19: #include "pa_request.h"
1.1 paf 20:
1.11 misha 21: #define HTTP_COOKIES_NAME "cookies"
1.12 moko 22:
1.1 paf 23: #ifndef DOXYGEN
24: struct File_read_http_result {
25: char *str; size_t length;
26: HashStringValue* headers;
27: };
28: #endif
29:
1.15 moko 30: class ResponseHeaders {
31: public:
32: class Header {
33: public:
34: String::Body name;
35: String::Body value;
36:
37: Header(String::Body aname, String::Body avalue) : name(aname), value(avalue) {}
38:
39: void transcode(Charset &charset, Charset &source){
40: name=Charset::transcode(name, charset, source);
41: value=Charset::transcode(value, charset, source);
42: }
43:
44: };
45:
46: Array<Header> headers;
47:
48: String::Body content_type;
49:
50: bool add_header(const char *line){
51: const char *value=strchr(line, ':');
52:
53: if(value && value != line){ // we need only headers, not the response code
54: Header header(str_upper(line, value-line), String::Body(value+1).trim(String::TRIM_BOTH, " \t\n\r"));
55:
56: if(header.name == String::Body(HTTP_CONTENT_TYPE_UPPER) && content_type.is_empty())
57: content_type=header.value;
58:
59: headers+=header;
60:
61: return true;
62: }
63: return false;
64: }
65:
66: };
67:
1.9 misha 68: Table* parse_cookies(Request& r, Table *cookies);
1.16 ! moko 69: void tables_update(HashStringValue& tables, const String::Body name, const String& value);
1.9 misha 70:
1.6 moko 71: char *pa_http_safe_header_name(const char *name);
72:
1.15 moko 73: File_read_http_result pa_internal_file_read_http(Request& r, const String& file_spec, bool as_text, HashStringValue *options=0, bool transcode_text_result=true);
1.1 paf 74:
75: #endif
E-mail: