~britco/nginx/master

« back to all changes in this revision

Viewing changes to modules/nginx-echo/src/ngx_http_echo_var.c

  • Committer: Bazaar Package Importer
  • Author(s): Kartik Mistry, Kartik Mistry, Michael Lustfield
  • Date: 2010-11-27 21:04:02 UTC
  • mfrom: (1.3.8 upstream)
  • mto: This revision was merged to the branch mainline in revision 36.
  • Revision ID: james.westby@ubuntu.com-20101127210402-14sgjpe6r3jup8a9
Tags: 0.8.53-1
[Kartik Mistry]
* debian/control:
  + Added Michael Lustfield as co-maintainer
* nginx.conf:
  + No need to use regex in gzip_disable for msie6, Thanks to António P. P.
    Almeida <appa@perusio.net> (Closes: #592147)
* conf/sites-available/default:
  + Fixed typo for "include fastcgi", Thanks to Mostafa Ghadamyari
    <nginx@gigfa.com> (Closes: #593142, #593143)
* debian/patches/fix_reloading_ipv6.diff:
  + Removed, merged upstream
* debian/init.d:
  + Added fix to control nginx by user in a simple way by setting DAEMON
    variable to an invalid name in /etc/default/nginx. Patch by Toni Mueller
    <support@oeko.net> (Closes: #594598)
* debian/NEWS.Debian:
  + Updated news for 0.8.x as stable branch

[Michael Lustfield]
* New upstream release (Closes: #602970)
  + 0.8.x branch is declared stable by upstream now
* Add a UFW profile set:
  + debian/nginx.ufw.profile: Added.
  + debian/control: nginx: Suggests ufw.
  + debian/dirs: Add 'etc/ufw/applications.d'
  + debian/rules: Add install rule for the nginx UFW profile.
* Moved debian/dirs to debian/nginx.dirs
* Added types_hash_max_size to nginx.conf
* Install simple default index.html file (Closes: #581416)
  + debian/dirs: Add 'usr/share/nginx/www'.
  + debian/nginx.install: Add 'html/* usr/share/nginx/www'.
* debian/patches/nginx-echo.diff:
  + Added Echo module
* Added files for nginx.docs
  - /usr/share/doc/nginx/
    + debian/help/docs/fcgiwrap
    + debian/help/docs/php
    + debian/help/docs/support-irc
    + debian/help/docs/upstream
* Added files for nginx.examples
  - /usr/share/doc/nginx/examples/
    + debian/help/docs/drupal
    + debian/help/docs/http
    + debian/help/docs/mail
    + debian/help/docs/mailman
    + debian/help/docs/nginx.conf
    + debian/help/docs/virtual_hosts
    + debian/help/docs/wordpress
* debian/conf/:
  + Removed excess spaces
  + Added tabs where appropriate
  + Added SCRIPT_FILENAME to fastcgi_params

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_var.h"
 
5
#include "ngx_http_echo_timer.h"
 
6
#include "ngx_http_echo_request_info.h"
 
7
#include "ngx_http_echo_foreach.h"
 
8
 
 
9
static ngx_int_t ngx_http_echo_incr_variable(ngx_http_request_t *r,
 
10
        ngx_http_variable_value_t *v, uintptr_t data);
 
11
 
 
12
static ngx_http_variable_t ngx_http_echo_variables[] = {
 
13
    { ngx_string("echo_timer_elapsed"), NULL,
 
14
      ngx_http_echo_timer_elapsed_variable, 0,
 
15
      NGX_HTTP_VAR_NOCACHEABLE, 0 },
 
16
 
 
17
    { ngx_string("echo_request_method"), NULL,
 
18
      ngx_http_echo_request_method_variable, 0,
 
19
      NGX_HTTP_VAR_NOCACHEABLE, 0 },
 
20
 
 
21
    { ngx_string("echo_cacheable_request_uri"), NULL,
 
22
      ngx_http_echo_cacheable_request_uri_variable, 0,
 
23
      0, 0 },
 
24
 
 
25
    { ngx_string("echo_request_uri"), NULL,
 
26
      ngx_http_echo_request_uri_variable, 0,
 
27
      0, 0 },
 
28
 
 
29
    { ngx_string("echo_client_request_method"), NULL,
 
30
      ngx_http_echo_client_request_method_variable, 0,
 
31
      NGX_HTTP_VAR_NOCACHEABLE, 0 },
 
32
 
 
33
    { ngx_string("echo_request_body"), NULL,
 
34
      ngx_http_echo_request_body_variable, 0,
 
35
      NGX_HTTP_VAR_NOCACHEABLE, 0 },
 
36
 
 
37
    { ngx_string("echo_client_request_headers"), NULL,
 
38
      ngx_http_echo_client_request_headers_variable, 0,
 
39
      NGX_HTTP_VAR_NOCACHEABLE, 0 },
 
40
 
 
41
    { ngx_string("echo_it"), NULL,
 
42
      ngx_http_echo_it_variable, 0,
 
43
      NGX_HTTP_VAR_NOCACHEABLE, 0 },
 
44
 
 
45
    { ngx_string("echo_incr"), NULL,
 
46
      ngx_http_echo_incr_variable, 0,
 
47
      NGX_HTTP_VAR_NOCACHEABLE, 0 },
 
48
 
 
49
    { ngx_string("echo_response_status"), NULL,
 
50
      ngx_http_echo_response_status_variable, 0,
 
51
      NGX_HTTP_VAR_NOCACHEABLE, 0 },
 
52
 
 
53
    { ngx_null_string, NULL, NULL, 0, 0, 0 }
 
54
};
 
55
 
 
56
ngx_int_t
 
57
ngx_http_echo_add_variables(ngx_conf_t *cf) {
 
58
    ngx_http_variable_t *var, *v;
 
59
    for (v = ngx_http_echo_variables; v->name.len; v++) {
 
60
        var = ngx_http_add_variable(cf, &v->name, v->flags);
 
61
        if (var == NULL) {
 
62
            return NGX_ERROR;
 
63
        }
 
64
        var->get_handler = v->get_handler;
 
65
        var->data = v->data;
 
66
    }
 
67
    return NGX_OK;
 
68
}
 
69
 
 
70
static ngx_int_t
 
71
ngx_http_echo_incr_variable(ngx_http_request_t *r,
 
72
        ngx_http_variable_value_t *v, uintptr_t data) {
 
73
    ngx_http_echo_ctx_t         *ctx;
 
74
    u_char                      *p;
 
75
 
 
76
    ctx = ngx_http_get_module_ctx(r->main, ngx_http_echo_module);
 
77
 
 
78
    if (ctx == NULL) {
 
79
        return NGX_ERROR;
 
80
    }
 
81
 
 
82
    ctx->counter++;
 
83
 
 
84
    p = ngx_palloc(r->pool, NGX_INT_T_LEN);
 
85
    if (p == NULL) {
 
86
        return NGX_ERROR;
 
87
    }
 
88
 
 
89
    v->len = ngx_sprintf(p, "%ui", ctx->counter) - p;
 
90
    v->data = p;
 
91
 
 
92
    v->valid = 1;
 
93
    v->not_found = 0;
 
94
    v->no_cacheable = 1;
 
95
 
 
96
    return NGX_OK;
 
97
}
 
98