nanohttp-server.c File Reference

#include "nanohttp-logging.h"
#include "nanohttp-error.h"
#include "nanohttp-common.h"
#include "nanohttp-socket.h"
#include "nanohttp-stream.h"
#include "nanohttp-request.h"
#include "nanohttp-response.h"
#include "nanohttp-server.h"
#include "nanohttp-base64.h"
#include "nanohttp-admin.h"

Go to the source code of this file.

Classes

struct  _conndata

Defines

#define timeradd(tvp, uvp, vvp)
#define timersub(tvp, uvp, vvp)
#define CONNECTION_FREE   0
#define CONNECTION_IN_USE   1

Typedefs

typedef _conndata conndata_t

Functions

herror_t httpd_init (int argc, char **argv)
herror_t httpd_register_secure (const char *context, httpd_service func, httpd_auth auth)
herror_t httpd_register (const char *context, httpd_service service)
herror_t httpd_register_default_secure (const char *context, httpd_service service, httpd_auth auth)
herror_t httpd_register_default (const char *context, httpd_service service)
short httpd_get_port (void)
int httpd_get_timeout (void)
void httpd_set_timeout (int secs)
const char * httpd_get_protocol (void)
int httpd_get_conncount (void)
hservice_thttpd_get_services (void)
int httpd_enable_service (hservice_t *service)
int httpd_disable_service (hservice_t *service)
hservice_thttpd_find_service (const char *context)
void httpd_response_set_content_type (httpd_conn_t *res, const char *content_type)
herror_t httpd_send_header (httpd_conn_t *res, int code, const char *text)
herror_t httpd_send_bad_request (httpd_conn_t *conn, const char *msg)
herror_t httpd_send_unauthorized (httpd_conn_t *conn, const char *realm)
herror_t httpd_send_not_found (httpd_conn_t *conn, const char *msg)
herror_t httpd_send_internal_error (httpd_conn_t *conn, const char *msg)
herror_t httpd_send_not_implemented (httpd_conn_t *conn, const char *msg)
httpd_conn_thttpd_new (struct hsocket_t *sock)
void httpd_free (httpd_conn_t *conn)
int httpd_set_header (httpd_conn_t *conn, const char *key, const char *value)
void httpd_set_headers (httpd_conn_t *conn, hpair_t *header)
int httpd_add_header (httpd_conn_t *conn, const char *key, const char *value)
void httpd_add_headers (httpd_conn_t *conn, const hpair_t *values)
herror_t httpd_run (void)
void httpd_destroy (void)
unsigned char * httpd_get_postdata (httpd_conn_t *conn, struct hrequest_t *req, long *received, long max)
herror_t httpd_mime_send_header (httpd_conn_t *conn, const char *related_start, const char *related_start_info, const char *related_type, int code, const char *text)
herror_t httpd_mime_next (httpd_conn_t *conn, const char *content_id, const char *content_type, const char *transfer_encoding)
herror_t httpd_mime_send_file (httpd_conn_t *conn, const char *content_id, const char *content_type, const char *transfer_encoding, const char *filename)
herror_t httpd_mime_end (httpd_conn_t *conn)


Define Documentation

#define CONNECTION_FREE   0
 

Definition at line 136 of file nanohttp-server.c.

#define CONNECTION_IN_USE   1
 

Definition at line 137 of file nanohttp-server.c.

Referenced by httpd_get_conncount().

#define timeradd tvp,
uvp,
vvp   ) 
 

Value:

do {                                                            \
                (vvp)->tv_sec = (tvp)->tv_sec + (uvp)->tv_sec;          \
                (vvp)->tv_usec = (tvp)->tv_usec + (uvp)->tv_usec;       \
                if ((vvp)->tv_usec >= 1000000) {                        \
                        (vvp)->tv_sec++;                                \
                        (vvp)->tv_usec -= 1000000;                      \
                }                                                       \
        } while (0)

Definition at line 100 of file nanohttp-server.c.

#define timersub tvp,
uvp,
vvp   ) 
 

Value:

do {                                                            \
                (vvp)->tv_sec = (tvp)->tv_sec - (uvp)->tv_sec;          \
                (vvp)->tv_usec = (tvp)->tv_usec - (uvp)->tv_usec;       \
                if ((vvp)->tv_usec < 0) {                               \
                        (vvp)->tv_sec--;                                \
                        (vvp)->tv_usec += 1000000;                      \
                }                                                       \
        } while (0)

Definition at line 112 of file nanohttp-server.c.


Typedef Documentation

typedef struct _conndata conndata_t
 


Function Documentation

int httpd_add_header httpd_conn_t conn,
const char *  key,
const char *  value
 

Definition at line 903 of file nanohttp-server.c.

References httpd_conn::header, hpairnode_new(), and log_warn1.

Referenced by httpd_add_headers().

void httpd_add_headers httpd_conn_t conn,
const hpair_t values
 

Definition at line 917 of file nanohttp-server.c.

References httpd_add_header(), hpair::key, log_warn1, hpair::next, and hpair::value.

void httpd_destroy void   ) 
 

See also:
httpd_init

Definition at line 1105 of file nanohttp-server.c.

References hsocket_module_destroy(), and tag_hservice::next.

Referenced by soap_nhttp_server_destroy().

int httpd_disable_service hservice_t service  ) 
 

Definition at line 442 of file nanohttp-server.c.

References NHTTPD_SERVICE_DOWN, and tag_hservice::status.

int httpd_enable_service hservice_t service  ) 
 

Definition at line 432 of file nanohttp-server.c.

References NHTTPD_SERVICE_UP, and tag_hservice::status.

hservice_t* httpd_find_service const char *  context  ) 
 

Definition at line 453 of file nanohttp-server.c.

References tag_hservice::context, and tag_hservice::next.

void httpd_free httpd_conn_t conn  ) 
 

Definition at line 630 of file nanohttp-server.c.

References httpd_conn::header, hpairnode_free_deep(), http_output_stream_free(), and httpd_conn::out.

int httpd_get_conncount void   ) 
 

Definition at line 399 of file nanohttp-server.c.

References CONNECTION_IN_USE.

short httpd_get_port void   ) 
 

Definition at line 373 of file nanohttp-server.c.

Referenced by soap_nhttp_get_port().

unsigned char* httpd_get_postdata httpd_conn_t conn,
struct hrequest_t req,
long *  received,
long  max
 

Definition at line 1124 of file nanohttp-server.c.

References hrequest_t::header, HEADER_CONTENT_LENGTH, hpairnode_get_ignore_case(), http_input_stream_read(), HTTP_REQUEST_POST, hrequest_t::in, log_error2, log_warn1, and hrequest_t::method.

const char* httpd_get_protocol void   ) 
 

Definition at line 393 of file nanohttp-server.c.

Referenced by soap_nhttp_get_protocol().

hservice_t* httpd_get_services void   ) 
 

Definition at line 413 of file nanohttp-server.c.

int httpd_get_timeout void   ) 
 

Definition at line 379 of file nanohttp-server.c.

References hsocket_get_timeout().

herror_t httpd_init int  argc,
char **  argv
 

Definition at line 270 of file nanohttp-server.c.

References H_OK, herror_message(), hsocket_bind(), hsocket_init(), hsocket_module_init(), and log_error2.

Referenced by soap_nhttp_server_init_args().

herror_t httpd_mime_end httpd_conn_t conn  ) 
 

Finish MIME request Returns: H_OK or error flag

Definition at line 1321 of file nanohttp-server.c.

References H_OK, http_output_stream_flush(), http_output_stream_write(), and httpd_conn::out.

herror_t httpd_mime_next httpd_conn_t conn,
const char *  content_id,
const char *  content_type,
const char *  transfer_encoding
 

Send boundary and part header and continue with next part

Definition at line 1243 of file nanohttp-server.c.

References H_OK, HEADER_CONTENT_ID, HEADER_CONTENT_TRANSFER_ENCODING, HEADER_CONTENT_TYPE, http_output_stream_write(), and httpd_conn::out.

Referenced by httpd_mime_send_file().

herror_t httpd_mime_send_file httpd_conn_t conn,
const char *  content_id,
const char *  content_type,
const char *  transfer_encoding,
const char *  filename
 

Send boundary and part header and continue with next part

Definition at line 1275 of file nanohttp-server.c.

References FILE_ERROR_OPEN, FILE_ERROR_READ, H_OK, herror_new(), http_output_stream_write(), httpd_mime_next(), MAX_FILE_BUFFER_SIZE, and httpd_conn::out.

herror_t httpd_mime_send_header httpd_conn_t conn,
const char *  related_start,
const char *  related_start_info,
const char *  related_type,
int  code,
const char *  text
 

Begin MIME multipart/related POST Returns: H_OK or error flag

Definition at line 1196 of file nanohttp-server.c.

References HEADER_CONTENT_TYPE, httpd_send_header(), and httpd_set_header().

httpd_conn_t* httpd_new struct hsocket_t sock  ) 
 

Definition at line 612 of file nanohttp-server.c.

References httpd_conn::content_type, httpd_conn::header, log_error2, httpd_conn::out, and httpd_conn::sock.

herror_t httpd_register const char *  context,
httpd_service  service
 

Definition at line 348 of file nanohttp-server.c.

References httpd_register_secure().

Referenced by httpd_admin_init_args(), soap_admin_init_args(), soap_nhttp_register(), and soap_wsil_init_args().

herror_t httpd_register_default const char *  context,
httpd_service  service
 

Definition at line 367 of file nanohttp-server.c.

References httpd_register_default_secure().

herror_t httpd_register_default_secure const char *  context,
httpd_service  service,
httpd_auth  auth
 

Definition at line 354 of file nanohttp-server.c.

References httpd_register_secure().

Referenced by httpd_register_default().

herror_t httpd_register_secure const char *  context,
httpd_service  func,
httpd_auth  auth
 

Definition at line 306 of file nanohttp-server.c.

References tag_hservice::auth, tag_hservice::context, tag_hservice::func, H_OK, herror_new(), service_statistics::lock, log_error2, log_verbose3, tag_hservice::next, NHTTPD_SERVICE_UP, tag_hservice::statistics, tag_hservice::status, and service_statistics::time.

Referenced by httpd_register(), and httpd_register_default_secure().

void httpd_response_set_content_type httpd_conn_t res,
const char *  content_type
 

Definition at line 467 of file nanohttp-server.c.

References httpd_conn::content_type.

herror_t httpd_run void   ) 
 

Definition at line 1031 of file nanohttp-server.c.

References H_OK, herror_message(), hsocket_accept(), hsocket_close(), hsocket_listen(), log_error2, log_verbose1, and hsocket_t::sock.

Referenced by soap_nhttp_server_run().

herror_t httpd_send_bad_request httpd_conn_t conn,
const char *  msg
 

Send a minimalistic HTML error document with HTTP status 400.

See also:
HTTP_STATUS_400_REASON_PHRASE

Definition at line 552 of file nanohttp-server.c.

References HTTP_STATUS_400_REASON_PHRASE.

herror_t httpd_send_header httpd_conn_t res,
int  code,
const char *  text
 

Definition at line 475 of file nanohttp-server.c.

References H_OK, httpd_conn::header, hsocket_send(), http_output_stream_new(), hpair::key, hpair::next, httpd_conn::out, httpd_conn::sock, and hpair::value.

Referenced by httpd_mime_send_header().

herror_t httpd_send_internal_error httpd_conn_t conn,
const char *  msg
 

Send a minimalistic HTML error document with HTTP status 500.

See also:
HTTP_STATUS_500_REASON_PHRASE

Definition at line 575 of file nanohttp-server.c.

References HTTP_STATUS_500_REASON_PHRASE.

herror_t httpd_send_not_found httpd_conn_t conn,
const char *  msg
 

Send a minimalistic HTML error document with HTTP status 404.

See also:
HTTP_STATUS_404_REASON_PHRASE

Definition at line 569 of file nanohttp-server.c.

References HTTP_STATUS_404_REASON_PHRASE.

herror_t httpd_send_not_implemented httpd_conn_t conn,
const char *  msg
 

Send a minimalistic HTML error document with HTTP status 501.

See also:
HTTP_STATUS_501_REASON_PHRASE

Definition at line 581 of file nanohttp-server.c.

References HTTP_STATUS_501_REASON_PHRASE.

herror_t httpd_send_unauthorized httpd_conn_t conn,
const char *  realm
 

Send a minimalistc HTML error document with HTTP status 401.

See also:
HTTP_STATUS_401_REASON_PHRASE

Definition at line 558 of file nanohttp-server.c.

References HEADER_WWW_AUTHENTICATE, HTTP_STATUS_401_REASON_PHRASE, and httpd_set_header().

int httpd_set_header httpd_conn_t conn,
const char *  key,
const char *  value
 

Definition at line 866 of file nanohttp-server.c.

References httpd_conn::header, hpairnode_new(), hpair::key, log_warn1, hpair::next, and hpair::value.

Referenced by httpd_mime_send_header(), httpd_send_unauthorized(), and httpd_set_headers().

void httpd_set_headers httpd_conn_t conn,
hpair_t header
 

Definition at line 892 of file nanohttp-server.c.

References httpd_set_header(), hpair::key, hpair::next, and hpair::value.

void httpd_set_timeout int  secs  ) 
 

Definition at line 385 of file nanohttp-server.c.

References hsocket_set_timeout().


Generated on Thu Jan 25 23:36:03 2007 for csoap by  doxygen 1.4.6