Skip to content

Commit

Permalink
minor code and test cleanup.
Browse files Browse the repository at this point in the history
  • Loading branch information
agentzh committed Aug 16, 2011
1 parent a6f191f commit e056614
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 7 deletions.
3 changes: 2 additions & 1 deletion src/ngx_http_set_hmac.c
@@ -1,6 +1,7 @@
#define DDEBUG 0
#include "ddebug.h"
#include <ndk.h>

#include <ndk.h>

#include "ngx_http_set_hmac.h"
#include <openssl/evp.h>
Expand Down
4 changes: 2 additions & 2 deletions src/ngx_http_set_local_today.c
Expand Up @@ -20,7 +20,7 @@ ngx_http_set_local_today(ngx_http_request_t *r, ngx_str_t *res,

dd("tm.ngx_tm_hour:%d", tm.ngx_tm_hour);

p = ngx_palloc(r->pool, sizeof("xxxx-xx-xx") - 1);
p = ngx_palloc(r->pool, sizeof("yyyy-mm-dd") - 1);
if (p == NULL) {
return NGX_ERROR;
}
Expand All @@ -29,7 +29,7 @@ ngx_http_set_local_today(ngx_http_request_t *r, ngx_str_t *res,
tm.ngx_tm_mday);

res->data = p;
res->len = sizeof("xxxx-xx-xx") - 1;
res->len = sizeof("yyyy-mm-dd") - 1;

return NGX_OK;
}
Expand Down
18 changes: 18 additions & 0 deletions t/hex.t
Expand Up @@ -38,3 +38,21 @@ __DATA__
GET /bar
--- response_body
abcde
=== TEST 3: hex encode (chinese)
--- config
location /bar {
set $raw "章亦春";
set_encode_hex $digest $raw;
set_decode_hex $hex $digest;
echo $digest;
echo $hex;
}
--- request
GET /bar
--- response_body
e7aba0e4baa6e698a5
章亦春
9 changes: 5 additions & 4 deletions t/local-today.t
Expand Up @@ -2,9 +2,10 @@

use lib 'lib';
use Test::Nginx::Socket;
our($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst)
= localtime();
our $str = sprintf("%04d-%02d-%02d\n", $main::year + 1900, $main::mon + 1, $main::mday);

my ($sec, $min, $hour, $mday, $mon, $year) = localtime;

our $str = sprintf("%04d-%02d-%02d\n", $year + 1900, $mon + 1, $mday);
#repeat_each(3);

plan tests => repeat_each() * 2 * blocks();
Expand All @@ -17,7 +18,7 @@ run_tests();

__DATA__
=== TEST 1: set if empty
=== TEST 1: sanity
--- config
location /foo {
set_local_today $today;
Expand Down

0 comments on commit e056614

Please sign in to comment.