~ubuntu-branches/ubuntu/lucid/nginx/lucid-updates

« back to all changes in this revision

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

  • Committer: Bazaar Package Importer
  • Author(s): Bhavani Shankar
  • Date: 2008-12-01 20:11:53 UTC
  • mfrom: (4.1.2 sid)
  • Revision ID: james.westby@ubuntu.com-20081201201153-q0ap33bcphfxriy3
Tags: 0.6.34-1ubuntu1
* Merge from debian unstable, remaining changes: (LP: #303916)
  + debian/control:
    - Add Depend on lsb >= 3.2-14, which has the status_of_proc() function.
  + debian/init.d:
    - Add sourcing to '. /lib/lsb/init-functions'
    - Add the 'status' action
  + Fixed FTBFS by properly defining IOV_MAX to its Linux equivelent.
  + Added dpatch based patch system

Show diffs side-by-side

added added

removed removed

Lines of Context:
48
48
ngx_http_static_handler(ngx_http_request_t *r)
49
49
{
50
50
    u_char                    *last, *location;
51
 
    size_t                     root;
 
51
    size_t                     root, len;
52
52
    ngx_str_t                  path;
53
53
    ngx_int_t                  rc;
54
54
    ngx_uint_t                 level;
58
58
    ngx_open_file_info_t       of;
59
59
    ngx_http_core_loc_conf_t  *clcf;
60
60
 
61
 
    if (!(r->method & (NGX_HTTP_GET|NGX_HTTP_HEAD))) {
 
61
    if (!(r->method & (NGX_HTTP_GET|NGX_HTTP_HEAD|NGX_HTTP_POST))) {
62
62
        return NGX_HTTP_NOT_ALLOWED;
63
63
    }
64
64
 
71
71
        return NGX_DECLINED;
72
72
    }
73
73
 
74
 
    rc = ngx_http_discard_request_body(r);
75
 
 
76
 
    if (rc != NGX_OK) {
77
 
        return rc;
78
 
    }
79
 
 
80
74
    log = r->connection->log;
81
75
 
82
76
    /*
150
144
            return NGX_HTTP_INTERNAL_SERVER_ERROR;
151
145
        }
152
146
 
153
 
        if (!clcf->alias && clcf->root_lengths == NULL) {
 
147
        len = r->uri.len + 1;
 
148
 
 
149
        if (!clcf->alias && clcf->root_lengths == NULL && r->args.len == 0) {
154
150
            location = path.data + clcf->root.len;
155
151
 
 
152
            *last = '/';
 
153
 
156
154
        } else {
157
 
            location = ngx_palloc(r->pool, r->uri.len + 1);
 
155
            if (r->args.len) {
 
156
                len += r->args.len + 1;
 
157
            }
 
158
 
 
159
            location = ngx_palloc(r->pool, len);
158
160
            if (location == NULL) {
159
161
                return NGX_HTTP_INTERNAL_SERVER_ERROR;
160
162
            }
161
163
 
162
164
            last = ngx_copy(location, r->uri.data, r->uri.len);
 
165
 
 
166
            *last = '/';
 
167
 
 
168
            if (r->args.len) {
 
169
                *++last = '?';
 
170
                ngx_memcpy(++last, r->args.data, r->args.len);
 
171
            }
163
172
        }
164
173
 
165
 
        *last = '/';
166
 
 
167
174
        /*
168
175
         * we do not need to set the r->headers_out.location->hash and
169
176
         * r->headers_out.location->key fields
170
177
         */
171
178
 
172
 
        r->headers_out.location->value.len = r->uri.len + 1;
 
179
        r->headers_out.location->value.len = len;
173
180
        r->headers_out.location->value.data = location;
174
181
 
175
182
        return NGX_HTTP_MOVED_PERMANENTLY;
186
193
 
187
194
#endif
188
195
 
 
196
    if (r->method & NGX_HTTP_POST) {
 
197
        return NGX_HTTP_NOT_ALLOWED;
 
198
    }
 
199
 
 
200
    rc = ngx_http_discard_request_body(r);
 
201
 
 
202
    if (rc != NGX_OK) {
 
203
        return rc;
 
204
    }
 
205
 
189
206
    log->action = "sending response to client";
190
207
 
191
208
    r->headers_out.status = NGX_HTTP_OK;