Movatterモバイル変換


[0]ホーム

URL:


 / 
Nginx-HTTP-0.04
River stage zero No dependents
/Nginx::HTTP

NAME

Nginx::HTTP - asynchronous http client for nginx-perl

SYNOPSIS

use Nginx;use Nginx::HTTP;ngx_http "1.2.3.4:80", "GET / HTTP/1.1"   . "\x0d\x0a" .                       "Host: localhost"  . "\x0d\x0a" .                       ""                 . "\x0d\x0a"   , sub {        my ($headers, $buf_ref) = @_;        unless ($headers) {        ngx_log_error $!, "error";        return;    }        ngx_log_notice 0, "got $headers->{'_status'}";    ...};

DESCRIPTION

Fast and simple asynchronous http client fornginx-perl. Supports keepalive.

EXPORT

ngx_httpngx_http_client

FUNCTIONS

ngx_http "$ip:$port:key=value;key=value...", $request, sub { }

Establishes new connection with$ip:$port and sends raw HTTP request.$request should be either scalar or scalar reference. Additionally there are two options available:timeout andssl. E.g.:

ngx_http "1.2.3.4:443:ssl=1;timeout=15", ...ngx_http "1.2.3.4:80:timeout=15", ...ngx_http "1.2.3.4:80", ...

Calls back with parsed response header in$_[0] and scalar reference to the body in$_[1].

$headers =  {  _status        => 503,               content-type   => ['text/html'],               content-length => [1234],               ...                              };$body = \"foobar";

$body is cleared right after the callback, so you have to copy its content if you want to use it later.

On error calls back without any arguments. Tries to reconnect on the next request.

For now every connection is cached forever. But you can usengx_http_client to create desired caching behaviour.

ngx_http "1.2.3.4:80", "GET / HTTP/1.1"   . "\x0d\x0a" .                       "Host: localhost"  . "\x0d\x0a" .                       ""                 . "\x0d\x0a"   , sub {        my ($headers, $body_ref) = @_;        unless ($headers) {        ngx_log_error $!, "error";        return;    }        ngx_log_notice 0, "got $headers->{'_status'}";    ...};

SEE ALSO

Nginx,HTTP::Parser2::XS

AUTHOR

Alexandr Gomoliako <zzz@zzz.org.ua>

LICENSE

Copyright 2012 Alexandr Gomoliako. All rights reserved.

This module is free software. It may be used, redistributed and/or modified under the same terms as Perl itself.

Module Install Instructions

To install Nginx::HTTP, copy and paste the appropriate command in to your terminal.

cpanm

cpanm Nginx::HTTP

CPAN shell

perl -MCPAN -e shellinstall Nginx::HTTP

For more information on module installation, please visitthe detailed CPAN module installation guide.

Keyboard Shortcuts

Global
sFocus search bar
?Bring up this help dialog
GitHub
gpGo to pull requests
gigo to github issues (only if github is preferred repository)
POD
gaGo to author
gcGo to changes
giGo to issues
gdGo to dist
grGo to repository/SCM
gsGo to source
gbGo to file browse
Search terms
module: (e.g.module:Plugin)
distribution: (e.g.distribution:Dancer auth)
author: (e.g.author:SONGMU Redis)
version: (e.g.version:1.00)

[8]ページ先頭

©2009-2025 Movatter.jp