src/http/modules/download/ngx_http_download_module.c File Reference

#include <ngx_config.h>
#include <ngx_core.h>
#include <ngx_http.h>
#include <ngx_log.h>
#include <libxml/parser.h>
#include <libxml/tree.h>
#include "ngx_http_download_module.h"

Go to the source code of this file.

Functions

static  void * ngx_http_download_create_conf (ngx_conf_t *cf)
 Nginx module configuration.
static char * ngx_http_download_merge_conf (ngx_conf_t *cf, void *parent, void *child)
 Nginx module configuration.
static ngx_int_t ngx_http_download_create_request (ngx_http_download_conn_t *conn)
 Creates HTTP request and store it in conn->request.
static ngx_int_t ngx_http_download_flush_buffer (ngx_http_download_conn_t *conn, ssize_t bytes)
 Moves bufferded data from conn->buffer to conn->out_bufs.
static void ngx_http_download_write_handler (ngx_event_t *wev)
 Handler called by nginx if socket is ready to write - write data to socket.
static void ngx_http_download_read_handler (ngx_event_t *rev)
 Handler called by nginx if socket is ready to read - read data from socket.
static void ngx_http_download_dummy_handler (ngx_event_t *ev)
 Handler that does nothing.
static void ngx_http_download_parse_headers (ngx_http_download_conn_t *conn)
 Tries to parse HTTP error code from headers, set conn->status.
static void ngx_http_download_finalize_connection (ngx_http_download_conn_t *conn, ngx_event_t *e, ngx_int_t rc)
 Closes connection and call done_handler if necessary.
ngx_http_download_conn_tngx_http_download_create_new (ngx_http_request_t *r)
 Creates and initializes new download structure.
ngx_int_t ngx_http_download_enqueue (ngx_http_download_conn_t *conn)
 Enqueues download, when finished done_handler will be called.
ngx_int_t ngx_http_download_parse_url (ngx_str_t *url, ngx_http_download_conn_t *conn)
 Parses url and put all required data to download structure.
void ngx_http_download_cleanup (ngx_http_download_conn_t *conn)
 Cancel download and free all allocated resources.

Variables

static ngx_command_t ngx_http_download_commands []
 Nginx config file commands configuration.
static ngx_http_module_t ngx_http_download_module_ctx
 Nginx module context.
ngx_module_t ngx_http_download_module
 Nginx module settings.

Function Documentation

void ngx_http_download_cleanup ( ngx_http_download_conn_t conn  ) 
static void * ngx_http_download_create_conf ( ngx_conf_t *  cf  )  [static]

Nginx module configuration.

Parameters:
cf config
Returns:
created configuration

Definition at line 747 of file ngx_http_download_module.c.

References ngx_http_download_conf_t::log, and ngx_http_download_conf_t::server_timeout.

ngx_http_download_conn_t* ngx_http_download_create_new ( ngx_http_request_t *  r  ) 
static ngx_int_t ngx_http_download_create_request ( ngx_http_download_conn_t conn  )  [static]

Creates HTTP request and store it in conn->request.

Parameters:
conn correctly initialized download structure
Returns:
operation status NGX_OK or NGX_ERROR on error

Definition at line 382 of file ngx_http_download_module.c.

References ngx_http_download_conn_s::host, ngx_http_download_conn_s::log, ngx_http_download_conn_s::pool, ngx_http_download_conn_s::request, and ngx_http_download_conn_s::uri.

Referenced by ngx_http_download_enqueue().

static void ngx_http_download_dummy_handler ( ngx_event_t *  ev  )  [static]

Handler that does nothing.

It's used by write_handler when all data was sent.

Parameters:
ev nginx event

Definition at line 530 of file ngx_http_download_module.c.

Referenced by ngx_http_download_write_handler().

ngx_int_t ngx_http_download_enqueue ( ngx_http_download_conn_t conn  ) 
static void ngx_http_download_finalize_connection ( ngx_http_download_conn_t conn,
ngx_event_t *  e,
ngx_int_t  rc 
) [static]
static ngx_int_t ngx_http_download_flush_buffer ( ngx_http_download_conn_t conn,
ssize_t  bytes 
) [static]

Moves bufferded data from conn->buffer to conn->out_bufs.

Parameters:
conn download structure
bytes number of bytes stored in conn->buffer
Returns:
NGX_OK or NGX_ERROR on error

Definition at line 417 of file ngx_http_download_module.c.

References ngx_http_download_conn_s::buffer, ngx_http_download_conn_s::out_bufs, ngx_http_download_conn_s::out_bufs_tail, ngx_http_download_conn_s::r, and ngx_http_download_conn_s::rpool.

Referenced by ngx_http_download_read_handler().

static char * ngx_http_download_merge_conf ( ngx_conf_t *  cf,
void *  parent,
void *  child 
) [static]

Nginx module configuration.

Parameters:
cf config
parent previous config
child config
Returns:
NGX_CONF_*

Definition at line 777 of file ngx_http_download_module.c.

References ngx_http_download_conf_t::server_timeout.

static void ngx_http_download_parse_headers ( ngx_http_download_conn_t conn  )  [static]

Tries to parse HTTP error code from headers, set conn->status.

Status will be set to -1 if parsing fail.

Parameters:
conn download structure

Definition at line 646 of file ngx_http_download_module.c.

References ngx_http_download_conn_s::body_start, ngx_http_download_conn_s::out_bufs, and ngx_http_download_conn_s::status.

Referenced by ngx_http_download_finalize_connection().

ngx_int_t ngx_http_download_parse_url ( ngx_str_t *  url,
ngx_http_download_conn_t conn 
)

Parses url and put all required data to download structure.

Parameters:
url correct url, ex. http://example.com/file.php?a=1
conn initialized download structure
Returns:
NGX_OK or NGX_ERROR on error

Definition at line 255 of file ngx_http_download_module.c.

References ngx_http_download_conn_s::err, ngx_http_download_conn_s::host, ngx_http_download_conn_s::pool, ngx_http_download_conn_s::port, and ngx_http_download_conn_s::uri.

Referenced by ngx_http_xslt2_xml_get_external_stylesheet(), and ngx_http_xxslt_parse_get_external_include().

static void ngx_http_download_read_handler ( ngx_event_t *  rev  )  [static]
static void ngx_http_download_write_handler ( ngx_event_t *  wev  )  [static]

Variable Documentation

ngx_command_t ngx_http_download_commands[] [static]
Initial value:
 {
                {ngx_string( "download_server_timeout" ),
                NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
                ngx_conf_set_msec_slot,
                NGX_HTTP_LOC_CONF_OFFSET,
                offsetof(ngx_http_download_conf_t, server_timeout),
                NULL},

                ngx_null_command
}

Nginx config file commands configuration.

Definition at line 40 of file ngx_http_download_module.c.

Initial value:
 {
                NGX_MODULE_V1,
                &ngx_http_download_module_ctx, 
                ngx_http_download_commands,   
                NGX_HTTP_MODULE,                           
                NULL,                                             
                NULL,                                             
                NULL,                                             
                NULL,                                             
                NULL,                                             
                NULL,                                             
                NULL,                                             
                NGX_MODULE_V1_PADDING
}

Nginx module settings.

Definition at line 59 of file ngx_http_download_module.c.

Referenced by ngx_http_download_create_new().

ngx_http_module_t ngx_http_download_module_ctx [static]
Initial value:
 {
                NULL,NULL,NULL,NULL,NULL,NULL,
                ngx_http_download_create_conf,
                ngx_http_download_merge_conf
}

Nginx module context.

Definition at line 52 of file ngx_http_download_module.c.


Generated on Mon Oct 12 14:03:36 2009 for XXSLT by  doxygen 1.6.1