~ubuntu-branches/ubuntu/quantal/nginx/quantal-updates

« back to all changes in this revision

Viewing changes to debian/modules/nginx-echo/src/ngx_http_echo_request_info.c

  • Committer: Bazaar Package Importer
  • Author(s): Michael Lustfield, Micheal Lustfield, Kartik Mistry
  • Date: 2011-03-03 23:39:07 UTC
  • mfrom: (4.2.29 sid)
  • Revision ID: james.westby@ubuntu.com-20110303233907-y48yifhfnn5qjuxz
Tags: 0.8.54-4
[Micheal Lustfield]
* debian/nginx-{full,light,extras}.default:
  + Added comment about alternative to ULIMIT.
* debian/nginx-{full,light,extras}.init.d:
  + Added quotes around a test variable. (Closes: #610946, LP: #699736)
* debian/patches/609343-log-time-iso8601.diff:
  + Added patch to add $time_iso8601 variable to logs. (Closes: #609343)
* Clean up old logrotate files. (Closes: #608983, Closes: #610289)
  + Added Files:
    - debian/nginx-common.preinst
  + Modified Files:
    - debian/rules
  + Moved debian/nginx-common.logrotate to debian/logrotate.
* Added common files to nginx-common package. (Closes: #610290)
  + Removed Files:
    - debian/nginx-full.dirs
    - debian/nginx-light.dirs
    - debian/nginx-full.install
    - debian/nginx-light.install
    - debian/nginx-extras.install
    - debian/nginx.*
  + Added Files:
    - debian/nginx-common.default
    - debian/nginx-common.dirs
    - debian/nginx-common.init.d
    - debian/nginx-common.install
    - debian/nginx-common.manpages
    - debian/logrotate
  + Modified Files:
    - debian/nginx-extras.dirs
    - debian/control
    - debian/rules
* debian/nginx-*.install: (Closes: #609797)
  + Removed NEWS.Debian from nginx-{full,light,extras}.install.
  + Added NEWS.Debian to nginx-common.install.
* nginx-common.postinst:
  + Enforce /var/log/nginx mode and user:group. (Closes: #610983)
  + Enforce /var/log/nginx/*.log mode and user:group. (Closes: #612832)
* debian/rules:
  + Added --with-file-aio to nginx-extras. (Closes: #613175)
  + Removed split clients and user id modules from nginx-light.
* debian/conf/sites-available/default:
  + Fixed a minor typo ( s/Quickstart/QuickStart/ ). (Closes: #613355)
* debian/conf/mime.types:
  + Changed xml type to application/xhtml+xml. (Closes: #613851)
* debian/help/docs/fcgiwrap:
  + Removed Ubuntu specific line in docs. (Closes: #614987)
* debian/conf/sites-available/default:
  + Fixed a pointer to a file. (Closes: #614980)

[Kartik Mistry]
* debian/*.lintian-overrides:
  + Add Lintian overrides for nginx man page. We've manpage in nginx-common
    binary

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#define DDEBUG 0
 
2
#include "ddebug.h"
 
3
 
 
4
#include "ngx_http_echo_request_info.h"
 
5
#include "ngx_http_echo_util.h"
 
6
#include "ngx_http_echo_handler.h"
 
7
 
 
8
#include <nginx.h>
 
9
 
 
10
 
 
11
static void ngx_http_echo_post_read_request_body(ngx_http_request_t *r);
 
12
 
 
13
ngx_int_t
 
14
ngx_http_echo_exec_echo_read_request_body(
 
15
        ngx_http_request_t* r, ngx_http_echo_ctx_t *ctx)
 
16
{
 
17
    return ngx_http_read_client_request_body(r,
 
18
            ngx_http_echo_post_read_request_body);
 
19
}
 
20
 
 
21
 
 
22
static void
 
23
ngx_http_echo_post_read_request_body(ngx_http_request_t *r)
 
24
{
 
25
    ngx_http_echo_ctx_t         *ctx;
 
26
 
 
27
    ctx = ngx_http_get_module_ctx(r, ngx_http_echo_module);
 
28
 
 
29
    dd("wait read request body %d", (int) ctx->wait_read_request_body);
 
30
 
 
31
    if (ctx->wait_read_request_body) {
 
32
        ctx->waiting = 0;
 
33
        ctx->done = 1;
 
34
 
 
35
        r->write_event_handler = ngx_http_echo_wev_handler;
 
36
 
 
37
        ngx_http_echo_wev_handler(r);
 
38
    }
 
39
}
 
40
 
 
41
 
 
42
/* this function's implementation is borrowed from nginx 0.8.20
 
43
 * and modified a bit to work with subrequests.
 
44
 * Copyrighted (C) by Igor Sysoev */
 
45
ngx_int_t
 
46
ngx_http_echo_request_method_variable(ngx_http_request_t *r,
 
47
        ngx_http_variable_value_t *v, uintptr_t data)
 
48
{
 
49
    if (r->method_name.data) {
 
50
        v->len = r->method_name.len;
 
51
        v->valid = 1;
 
52
        v->no_cacheable = 0;
 
53
        v->not_found = 0;
 
54
        v->data = r->method_name.data;
 
55
    } else {
 
56
        v->not_found = 1;
 
57
    }
 
58
 
 
59
    return NGX_OK;
 
60
}
 
61
 
 
62
 
 
63
/* this function's implementation is borrowed from nginx 0.8.20
 
64
 * and modified a bit to work with subrequests.
 
65
 * Copyrighted (C) by Igor Sysoev */
 
66
ngx_int_t
 
67
ngx_http_echo_client_request_method_variable(ngx_http_request_t *r,
 
68
        ngx_http_variable_value_t *v, uintptr_t data)
 
69
{
 
70
    if (r->main->method_name.data) {
 
71
        v->len = r->main->method_name.len;
 
72
        v->valid = 1;
 
73
        v->no_cacheable = 0;
 
74
        v->not_found = 0;
 
75
        v->data = r->main->method_name.data;
 
76
    } else {
 
77
        v->not_found = 1;
 
78
    }
 
79
 
 
80
    return NGX_OK;
 
81
}
 
82
 
 
83
 
 
84
/* this function's implementation is borrowed from nginx 0.8.20
 
85
 * and modified a bit to work with subrequests.
 
86
 * Copyrighted (C) by Igor Sysoev */
 
87
ngx_int_t
 
88
ngx_http_echo_request_body_variable(ngx_http_request_t *r,
 
89
        ngx_http_variable_value_t *v, uintptr_t data)
 
90
{
 
91
    u_char       *p;
 
92
    size_t        len;
 
93
    ngx_buf_t    *buf, *next;
 
94
    ngx_chain_t  *cl;
 
95
 
 
96
    if (r->request_body == NULL
 
97
        || r->request_body->bufs == NULL
 
98
        || r->request_body->temp_file)
 
99
    {
 
100
        v->not_found = 1;
 
101
 
 
102
        return NGX_OK;
 
103
    }
 
104
 
 
105
    cl = r->request_body->bufs;
 
106
    buf = cl->buf;
 
107
 
 
108
    if (cl->next == NULL) {
 
109
        v->len = buf->last - buf->pos;
 
110
        v->valid = 1;
 
111
        v->no_cacheable = 0;
 
112
        v->not_found = 0;
 
113
        v->data = buf->pos;
 
114
 
 
115
        return NGX_OK;
 
116
    }
 
117
 
 
118
    next = cl->next->buf;
 
119
    len = (buf->last - buf->pos) + (next->last - next->pos);
 
120
 
 
121
    p = ngx_pnalloc(r->pool, len);
 
122
    if (p == NULL) {
 
123
        return NGX_ERROR;
 
124
    }
 
125
 
 
126
    v->data = p;
 
127
 
 
128
    p = ngx_cpymem(p, buf->pos, buf->last - buf->pos);
 
129
    ngx_memcpy(p, next->pos, next->last - next->pos);
 
130
 
 
131
    v->len = len;
 
132
    v->valid = 1;
 
133
    v->no_cacheable = 0;
 
134
    v->not_found = 0;
 
135
 
 
136
    return NGX_OK;
 
137
}
 
138
 
 
139
 
 
140
ngx_int_t
 
141
ngx_http_echo_client_request_headers_variable(ngx_http_request_t *r,
 
142
        ngx_http_variable_value_t *v, uintptr_t data)
 
143
{
 
144
    size_t                      size;
 
145
    u_char                      *p, *last;
 
146
    ngx_buf_t                   *header_in;
 
147
    ngx_flag_t                  just_seen_crlf;
 
148
 
 
149
    if (r != r->main) {
 
150
        header_in = r->main->header_in;
 
151
    } else {
 
152
        header_in = r->header_in;
 
153
    }
 
154
 
 
155
    if (header_in == NULL) {
 
156
        v->not_found = 1;
 
157
        return NGX_OK;
 
158
    }
 
159
 
 
160
    size = header_in->pos - header_in->start;
 
161
 
 
162
    v->data = ngx_palloc(r->pool, size);
 
163
    last = ngx_cpymem(v->data, header_in->start, size);
 
164
 
 
165
    /* fix \0 introduced by the nginx header parser and
 
166
     * locate the end of the header */
 
167
    just_seen_crlf = 0;
 
168
    for (p = (u_char*)v->data; p != last; p++) {
 
169
        if (*p == '\0') {
 
170
            if (p + 1 != last && *(p + 1) == LF) {
 
171
                just_seen_crlf = 1;
 
172
                *p = CR;
 
173
            } else {
 
174
                *p = ':';
 
175
                just_seen_crlf = 0;
 
176
            }
 
177
        } else if (*p == CR) {
 
178
            if (just_seen_crlf) {
 
179
                *p = '\0';
 
180
                last = p;
 
181
                break;
 
182
            }
 
183
        } else if (*p != LF) {
 
184
            just_seen_crlf = 0;
 
185
        }
 
186
    }
 
187
 
 
188
    v->len = last - v->data;
 
189
    v->valid = 1;
 
190
    v->no_cacheable = 0;
 
191
    v->not_found = 0;
 
192
 
 
193
    return NGX_OK;
 
194
}
 
195
 
 
196
 
 
197
ngx_int_t
 
198
ngx_http_echo_cacheable_request_uri_variable(ngx_http_request_t *r,
 
199
        ngx_http_variable_value_t *v, uintptr_t data)
 
200
{
 
201
    if (r->uri.len) {
 
202
        v->len = r->uri.len;
 
203
        v->valid = 1;
 
204
        v->no_cacheable = 0;
 
205
        v->not_found = 0;
 
206
        v->data = r->uri.data;
 
207
    } else {
 
208
        v->not_found = 1;
 
209
    }
 
210
 
 
211
    return NGX_OK;
 
212
}
 
213
 
 
214
 
 
215
ngx_int_t
 
216
ngx_http_echo_request_uri_variable(ngx_http_request_t *r,
 
217
        ngx_http_variable_value_t *v, uintptr_t data)
 
218
{
 
219
    if (r->uri.len) {
 
220
        v->len = r->uri.len;
 
221
        v->valid = 1;
 
222
        v->no_cacheable = 1;
 
223
        v->not_found = 0;
 
224
        v->data = r->uri.data;
 
225
    } else {
 
226
        v->not_found = 1;
 
227
    }
 
228
 
 
229
    return NGX_OK;
 
230
}
 
231
 
 
232
 
 
233
ngx_int_t
 
234
ngx_http_echo_response_status_variable(ngx_http_request_t *r,
 
235
        ngx_http_variable_value_t *v, uintptr_t data)
 
236
{
 
237
    u_char                      *p;
 
238
 
 
239
    if (r->headers_out.status) {
 
240
        dd("headers out status: %d", (int) r->headers_out.status);
 
241
 
 
242
        p = ngx_palloc(r->pool, NGX_INT_T_LEN);
 
243
        if (p == NULL) {
 
244
            return NGX_ERROR;
 
245
        }
 
246
 
 
247
        v->len = ngx_sprintf(p, "%ui", r->headers_out.status) - p;
 
248
        v->data = p;
 
249
 
 
250
        v->valid = 1;
 
251
        v->no_cacheable = 1;
 
252
        v->not_found = 0;
 
253
    } else {
 
254
        v->not_found = 1;
 
255
    }
 
256
 
 
257
    return NGX_OK;
 
258
}
 
259