~ubuntu-branches/debian/squeeze/nginx/squeeze

« back to all changes in this revision

Viewing changes to src/http/modules/ngx_http_addition_filter_module.c

  • Committer: Bazaar Package Importer
  • Author(s): Fabio Tranchitella
  • Date: 2009-05-31 18:38:56 UTC
  • mfrom: (1.1.10 upstream) (4.1.12 experimental)
  • Revision ID: james.westby@ubuntu.com-20090531183856-3xhvf6wd0bw5556i
Tags: 0.7.59-1
* New upstream release, first in Debian for the 0.7 branch. Among other
  issues, it also fixes the problem with wildcard dns names used with SSL.
  (Closes: #515904)
* debian/watch: updated.
* debian/postinst: fixed a bashism. (Closes: #507913)
* debian/conf/nginx.conf: removed default_type. (Closes: #509390)
* debian/control: updated Standards-Version to 3.8.1, no changes needed.
* debian/NEWS.Debian: documented the issues with
  server_names_hash_bucket_size. (Closes: #524785)

Show diffs side-by-side

added added

removed removed

Lines of Context:
10
10
 
11
11
 
12
12
typedef struct {
13
 
    ngx_str_t   before_body;
14
 
    ngx_str_t   after_body;
 
13
    ngx_str_t     before_body;
 
14
    ngx_str_t     after_body;
 
15
 
 
16
    ngx_hash_t    types;
 
17
    ngx_array_t  *types_keys;
15
18
} ngx_http_addition_conf_t;
16
19
 
17
20
 
18
21
typedef struct {
19
 
    ngx_uint_t  before_body_sent;
 
22
    ngx_uint_t    before_body_sent;
20
23
} ngx_http_addition_ctx_t;
21
24
 
22
25
 
42
45
      offsetof(ngx_http_addition_conf_t, after_body),
43
46
      NULL },
44
47
 
 
48
    { ngx_string("addtion_types"),
 
49
      NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_1MORE,
 
50
      ngx_http_types_slot,
 
51
      NGX_HTTP_LOC_CONF_OFFSET,
 
52
      offsetof(ngx_http_addition_conf_t, types_keys),
 
53
      &ngx_http_html_default_types[0] },
 
54
 
45
55
      ngx_null_command
46
56
};
47
57
 
87
97
    ngx_http_addition_ctx_t   *ctx;
88
98
    ngx_http_addition_conf_t  *conf;
89
99
 
90
 
    if (r->headers_out.status != NGX_HTTP_OK
91
 
        || r != r->main
92
 
        || r->headers_out.content_type.data == NULL)
93
 
    {
 
100
    if (r->headers_out.status != NGX_HTTP_OK || r != r->main) {
94
101
        return ngx_http_next_header_filter(r);
95
102
    }
96
103
 
100
107
        return ngx_http_next_header_filter(r);
101
108
    }
102
109
 
103
 
    if (ngx_strncasecmp(r->headers_out.content_type.data,
104
 
                        (u_char *) "text/html", sizeof("text/html") - 1)
105
 
        != 0)
106
 
    {
 
110
    if (ngx_http_test_content_type(r, &conf->types) == NULL) {
107
111
        return ngx_http_next_header_filter(r);
108
112
    }
109
113
 
147
151
        ctx->before_body_sent = 1;
148
152
 
149
153
        if (conf->before_body.len) {
150
 
            rc = ngx_http_subrequest(r, &conf->before_body, NULL, &sr, NULL, 0);
151
 
 
152
 
            if (rc == NGX_ERROR || rc == NGX_DONE) {
153
 
                return rc;
 
154
            if (ngx_http_subrequest(r, &conf->before_body, NULL, &sr, NULL, 0)
 
155
                != NGX_OK)
 
156
            {
 
157
                return NGX_ERROR;
154
158
            }
155
159
        }
156
160
    }
176
180
        return rc;
177
181
    }
178
182
 
179
 
    rc = ngx_http_subrequest(r, &conf->after_body, NULL, &sr, NULL, 0);
180
 
 
181
 
    if (rc == NGX_ERROR || rc == NGX_DONE) {
182
 
        return rc;
 
183
    if (ngx_http_subrequest(r, &conf->after_body, NULL, &sr, NULL, 0)
 
184
        != NGX_OK)
 
185
    {
 
186
        return NGX_ERROR;
183
187
    }
184
188
 
185
189
    ngx_http_set_ctx(r, NULL, ngx_http_addition_filter_module);
214
218
    /*
215
219
     * set by ngx_pcalloc():
216
220
     *
217
 
     *     conf->before_body.len = 0;
218
 
     *     conf->before_body.date = NULL;
219
 
     *     conf->after_body.len = 0;
220
 
     *     conf->after_body.date = NULL;
 
221
     *     conf->before_body = { 0, NULL };
 
222
     *     conf->after_body = { 0, NULL };
 
223
     *     conf->types = { NULL };
 
224
     *     conf->types_keys = NULL;
221
225
     */
222
226
 
223
227
    return conf;
233
237
    ngx_conf_merge_str_value(conf->before_body, prev->before_body, "");
234
238
    ngx_conf_merge_str_value(conf->after_body, prev->after_body, "");
235
239
 
 
240
    if (ngx_http_merge_types(cf, conf->types_keys, &conf->types,
 
241
                             prev->types_keys, &prev->types,
 
242
                             ngx_http_html_default_types)
 
243
        != NGX_OK)
 
244
    {
 
245
        return NGX_CONF_ERROR;
 
246
    }
 
247
 
236
248
    return NGX_CONF_OK;
237
249
}