r17872 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r17871‎ | r17872 | r17873 >
Date:01:22, 23 November 2006
Author:river
Status:old
Tags:
Comment:
obsolete
Modified paths:
  • /trunk/willow/src/include/whttp_entity.h (deleted) (history)

Diff [purge]

Index: trunk/willow/src/include/whttp_entity.h
@@ -1,181 +0,0 @@
2 -/* @(#) $Id$ */
3 -/* This source code is in the public domain. */
4 -/*
5 - * Willow: Lightweight HTTP reverse-proxy.
6 - * whttp_entity: HTTP entity handling.
7 - */
8 -
9 -#ifndef WHTTP_ENTITY
10 -#define WHTTP_ENTITY
11 -
12 -#if defined __SUNPRO_C || defined __DECC || defined __HP_cc
13 -# pragma ident "@(#)$Id$"
14 -#endif
15 -
16 -#include <set>
17 -using std::set;
18 -
19 -#include <zlib.h>
20 -
21 -#include "whttp.h"
22 -#include "whttp_header.h"
23 -#include "queue.h"
24 -
25 -#define ENT_SOURCE_BUFFER 1
26 -#define ENT_SOURCE_FDE 2
27 -#define ENT_SOURCE_NONE 3
28 -#define ENT_SOURCE_FILE 4
29 -
30 -#define ENT_ERR_READERR -1 /* read error while parsing headers */
31 -#define ENT_ERR_INVHDR -2 /* invalid headers */
32 -#define ENT_ERR_INVHOST -3 /* invalid Host: */
33 -#define ENT_ERR_INVREQ -4 /* invalid request type */
34 -#define ENT_ERR_2MANY -5 /* too many headers */
35 -#define ENT_ERR_LOOP -6 /* forwarding loop detected */
36 -#define ENT_ERR_INVAE -7 /* invalid accept-encoding */
37 -
38 -extern struct request_type supported_reqtypes[];
39 -
40 -#define TE_CHUNKED 0x1 /* Chunked encoding */
41 -
42 -#define ENT_CHUNKED_OKAY 0x1
43 -
44 -extern const char *ent_errors[];
45 -
46 -#define MAX_HEADERS 64 /* maximum # of headers to allow */
47 -
48 -#define HAS_BODY(x) ((x) != 304)
49 -
50 -struct http_entity;
51 -struct http_client;
52 -
53 -struct bufferevent;
54 -
55 -typedef void (*header_cb)(struct http_entity *, void *, int);
56 -typedef void (*cache_callback)(const char *, size_t, void *);
57 -
58 -enum encoding {
59 - E_NONE = 0,
60 - E_DEFLATE,
61 - E_X_DEFLATE,
62 - E_GZIP,
63 - E_X_GZIP
64 -};
65 -
66 -struct http_entity : freelist_allocator<http_entity> {
67 - http_entity() {
68 - he_extraheaders = evbuffer_new();
69 - }
70 -
71 - ~http_entity() {
72 - if (_he_frombuf) {
73 - bufferevent_disable(_he_frombuf, EV_READ | EV_WRITE);
74 - bufferevent_free(_he_frombuf);
75 - }
76 - if (_he_tobuf) {
77 - bufferevent_disable(_he_tobuf, EV_READ | EV_WRITE);
78 - bufferevent_free(_he_tobuf);
79 - }
80 - if (he_reqstr)
81 - wfree(he_reqstr);
82 - delete[] _he_hdrbuf;
83 - evbuffer_free(he_extraheaders);
84 - }
85 -
86 - struct {
87 - /* response-only data */
88 - struct {
89 - int status;
90 - const char *status_str;
91 - } response;
92 - /* request-only data */
93 - struct {
94 - int reqtype;
95 - char *path;
96 - int httpmaj, httpmin;
97 - /*
98 - * Interesting headers.
99 - */
100 - char *host; /* Host */
101 - int contlen; /* Content-Length */
102 - set<qvalue> accept_encoding;
103 - } request;
104 - } he_rdata;
105 -
106 - char *he_h_pragma;
107 - char *he_h_cache_control;
108 - char *he_h_transfer_encoding;
109 - char *he_h_if_modified_since;
110 - char *he_h_last_modified;
111 - char *he_reqstr;
112 -struct header_list he_headers;
113 -struct evbuffer *he_extraheaders;
114 - int he_source_type;
115 -
116 - union {
117 - /* buffer data */
118 - struct {
119 - const char *addr;
120 - int len;
121 - } buffer;
122 - /* sendfile data */
123 - struct {
124 - int fd;
125 - size_t size;
126 - off_t off;
127 - } fd;
128 - /* fde data */
129 - struct {
130 - struct fde *fde;
131 - int len; /* or -1 */
132 - int _wrt; /* amount left to write */
133 - } fde;
134 - } he_source;
135 -
136 - struct {
137 - unsigned int cachable:1;
138 - unsigned int response:1;
139 - unsigned int error:1;
140 - unsigned int hdr_only:1;
141 - unsigned int eof:1;
142 - unsigned int drained:1;
143 - unsigned int chunked:1;
144 - } he_flags;
145 -
146 - int he_te; /* transfer encoding */
147 -enum encoding he_encoding;
148 -
149 - /*
150 - * If you want a callback when each piece of data is written, set this.
151 - * This only works when sending from an FDE, not when using a buffer
152 - * (if you use a buffer, you already have the data...)
153 - */
154 - cache_callback he_cache_callback;
155 - void *he_cache_callback_data;
156 -
157 - size_t he_size;
158 -
159 - /*
160 - * This is internal to whttp_entity. Don't touch it.
161 - */
162 - void *_he_cbdata;
163 - header_cb _he_func;
164 -struct fde *_he_target;
165 - int _he_state;
166 - int _he_chunk_size; /* For chunked encoding */
167 -struct bufferevent *_he_frombuf;
168 -struct bufferevent *_he_tobuf;
169 - z_stream _he_zbuf;
170 - size_t _he_hdroff; /* internal use by entity_read_callback */
171 - char *_he_hdrbuf; /* '' '' */
172 -};
173 -
174 - void entity_read_headers (struct http_entity *, header_cb, void *);
175 - void entity_send (struct fde *, struct http_entity *, header_cb, void *, int);
176 - void entity_set_response (struct http_entity *, int isresp);
177 -
178 - int qvalue_parse (set<qvalue> &list, const char *header);
179 - bool qvalue_remove_best (set<qvalue> &list, qvalue &);
180 -enum encoding accept_encoding (const char *ent);
181 -
182 -#endif