| | 87 | =head1 NAME |
| | 88 | |
| | 89 | HTTP::Engine::Test::Request - HTTP::Engine request object builder for test |
| | 90 | |
| | 91 | =head1 SYNOPSIS |
| | 92 | |
| | 93 | use HTTP::Engine::Test::Request; |
| | 94 | |
| | 95 | # simple query |
| | 96 | my $req = HTTP::Engine::Test::Request->new( |
| | 97 | uri => 'http://example.com/?foo=bar&bar=baz' |
| | 98 | ); |
| | 99 | is $req->method, 'GET', 'GET method'; |
| | 100 | is $req->address, '127.0.0.1', 'remote address'; |
| | 101 | is $req->uri, 'http://example.com/?foo=bar&bar=baz', 'uri'; |
| | 102 | is_deeply $req->parameters, { foo => 'bar', bar => 'baz' }, 'query params'; |
| | 103 | |
| | 104 | # use headers |
| | 105 | my $req = HTTP::Engine::Test::Request->new( |
| | 106 | uri => 'http://example.com/', |
| | 107 | headers => { |
| | 108 | 'Content-Type' => 'text/plain', |
| | 109 | }, |
| | 110 | ); |
| | 111 | is $req->header('content-type'), 'text/plain', 'content-type'; |
| | 112 | |
| | 113 | # by HTTP::Request object |
| | 114 | my $req = HTTP::Engine::Test::Request->new( |
| | 115 | HTTP::Request->new( |
| | 116 | GET => 'http://example.com/?foo=bar&bar=baz', |
| | 117 | HTTP::Headers::Fast->new( |
| | 118 | 'Content-Type' => 'text/plain', |
| | 119 | ), |
| | 120 | ) |
| | 121 | ); |
| | 122 | |
| | 123 | is $req->method, 'GET', 'GET method'; |
| | 124 | is $req->address, '127.0.0.1', 'remote address'; |
| | 125 | is $req->uri, 'http://example.com/?foo=bar&bar=baz', 'uri'; |
| | 126 | is_deeply $req->parameters, { foo => 'bar', bar => 'baz' }, 'query params'; |
| | 127 | is $req->header('content-type'), 'text/plain', 'content-type'; |
| | 128 | |
| | 129 | |
| | 130 | =head1 DESCRIPTION |
| | 131 | |
| | 132 | HTTP::Engine::Test::Request is HTTP::Engine request object builder. |
| | 133 | |
| | 134 | Please use in a your test. |
| | 135 | |
| | 136 | =head1 SEE ALSO |
| | 137 | |
| | 138 | L<HTTP::Engine::Request> |
| | 139 | |
| | 140 | =head1 AUTHOR |
| | 141 | |
| | 142 | Kazuhiro Osawa E<lt>ko@yappo.ne.jpE<gt> |