response.c File Reference

Methods for managing response objects. More...

#include "internal.h"
#include "response.h"

Include dependency graph for response.c:

Go to the source code of this file.

Functions

static int add_response_entry (struct MHD_Response *response, enum MHD_ValueKind kind, const char *header, const char *content)
int MHD_add_response_header (struct MHD_Response *response, const char *header, const char *content)
int MHD_add_response_footer (struct MHD_Response *response, const char *footer, const char *content)
int MHD_del_response_header (struct MHD_Response *response, const char *header, const char *content)
int MHD_get_response_headers (struct MHD_Response *response, MHD_KeyValueIterator iterator, void *iterator_cls)
const char * MHD_get_response_header (struct MHD_Response *response, const char *key)
MHD_ResponseMHD_create_response_from_callback (uint64_t size, size_t block_size, MHD_ContentReaderCallback crc, void *crc_cls, MHD_ContentReaderFreeCallback crfc)
static ssize_t file_reader (void *cls, uint64_t pos, char *buf, size_t max)
static void free_callback (void *cls)
MHD_ResponseMHD_create_response_from_fd_at_offset (size_t size, int fd, off_t offset)
MHD_ResponseMHD_create_response_from_fd (size_t size, int fd)
MHD_ResponseMHD_create_response_from_data (size_t size, void *data, int must_free, int must_copy)
MHD_ResponseMHD_create_response_from_buffer (size_t size, void *buffer, enum MHD_ResponseMemoryMode mode)
void MHD_destroy_response (struct MHD_Response *response)
void MHD_increment_response_rc (struct MHD_Response *response)


Detailed Description

Methods for managing response objects.

Author:
Daniel Pittman

Christian Grothoff

Definition in file response.c.


Function Documentation

static int add_response_entry ( struct MHD_Response response,
enum MHD_ValueKind  kind,
const char *  header,
const char *  content 
) [static]

Add a header or footer line to the response.

Parameters:
response response to add a header to
kind header or footer
header the header to add
content value to add
Returns:
MHD_NO on error (i.e. invalid header or content format).

Definition at line 41 of file response.c.

References MHD_Response::first_header, MHD_HTTP_Header::header, MHD_HTTP_Header::kind, MHD_NO, MHD_YES, MHD_HTTP_Header::next, NULL, and MHD_HTTP_Header::value.

Referenced by MHD_add_response_footer(), and MHD_add_response_header().

Here is the caller graph for this function:

static ssize_t file_reader ( void *  cls,
uint64_t  pos,
char *  buf,
size_t  max 
) [static]

Given a file descriptor, read data from the file to generate the response.

Parameters:
cls pointer to the response
pos offset in the file to access
buf where to write the data
max number of bytes to write at most
Returns:
number of bytes written

Definition at line 270 of file response.c.

References MHD_Response::fd, and MHD_Response::fd_off.

Referenced by MHD_create_response_from_fd_at_offset().

Here is the caller graph for this function:

static void free_callback ( void *  cls  )  [static]

Destroy file reader context. Closes the file descriptor.

Parameters:
cls pointer to file descriptor

Definition at line 286 of file response.c.

References MHD_Response::fd.

Referenced by MHD_create_response_from_fd_at_offset().

Here is the caller graph for this function:

int MHD_add_response_footer ( struct MHD_Response response,
const char *  footer,
const char *  content 
)

Add a footer line to the response.

Parameters:
response response to remove a header from
footer the footer to delete
content value to delete
Returns:
MHD_NO on error (i.e. invalid footer or content format).

Definition at line 110 of file response.c.

References add_response_entry(), and MHD_FOOTER_KIND.

Here is the call graph for this function:

int MHD_add_response_header ( struct MHD_Response response,
const char *  header,
const char *  content 
)

Add a header line to the response.

Parameters:
response response to add a header to
header the header to add
content value to add
Returns:
MHD_NO on error (i.e. invalid header or content format).

Definition at line 91 of file response.c.

References add_response_entry(), and MHD_HEADER_KIND.

Referenced by add_extra_headers(), MHD_queue_auth_fail_response(), and MHD_queue_basic_auth_fail_response().

Here is the call graph for this function:

Here is the caller graph for this function:

struct MHD_Response* MHD_create_response_from_buffer ( size_t  size,
void *  buffer,
enum MHD_ResponseMemoryMode  mode 
)

Create a response object. The response object can be extended with header information and then be used any number of times.

Parameters:
size size of the data portion of the response
buffer size bytes containing the response's data portion
mode flags for buffer management
Returns:
NULL on error (i.e. invalid arguments, out of memory)

Definition at line 406 of file response.c.

References MHD_create_response_from_data(), MHD_RESPMEM_MUST_COPY, and MHD_RESPMEM_MUST_FREE.

Referenced by parse_connection_headers(), and transmit_error_response().

Here is the call graph for this function:

Here is the caller graph for this function:

struct MHD_Response* MHD_create_response_from_callback ( uint64_t  size,
size_t  block_size,
MHD_ContentReaderCallback  crc,
void *  crc_cls,
MHD_ContentReaderFreeCallback  crfc 
)

Create a response object. The response object can be extended with header information and then be used any number of times.

Parameters:
size size of the data portion of the response, MHD_SIZE_UNKNOWN for unknown
block_size preferred block size for querying crc (advisory only, MHD may still call crc using smaller chunks); this is essentially the buffer size used for IO, clients should pick a value that is appropriate for IO and memory performance requirements
crc callback to use to obtain response data
crc_cls extra argument to crc
crfc callback to call to free crc_cls resources
Returns:
NULL on error (i.e. invalid arguments, out of memory)

Definition at line 228 of file response.c.

References MHD_Response::crc, MHD_Response::crc_cls, MHD_Response::crfc, MHD_Response::data, MHD_Response::data_buffer_size, MHD_Response::fd, MHD_Response::mutex, NULL, MHD_Response::reference_count, and MHD_Response::total_size.

Referenced by MHD_create_response_from_fd_at_offset().

Here is the caller graph for this function:

struct MHD_Response* MHD_create_response_from_data ( size_t  size,
void *  data,
int  must_free,
int  must_copy 
)

Create a response object. The response object can be extended with header information and then be used any number of times.

Parameters:
size size of the data portion of the response
data the data itself
must_free libmicrohttpd should free data when done
must_copy libmicrohttpd must make a copy of data right away, the data maybe released anytime after this call returns
Returns:
NULL on error (i.e. invalid arguments, out of memory)

Definition at line 354 of file response.c.

References MHD_Response::crc, MHD_Response::crc_cls, MHD_Response::crfc, MHD_Response::data, MHD_Response::data_size, MHD_Response::fd, MHD_YES, MHD_Response::mutex, NULL, MHD_Response::reference_count, and MHD_Response::total_size.

Referenced by MHD_create_response_from_buffer().

Here is the caller graph for this function:

struct MHD_Response* MHD_create_response_from_fd ( size_t  size,
int  fd 
)

Create a response object. The response object can be extended with header information and then be used any number of times.

Parameters:
size size of the data portion of the response
fd file descriptor referring to a file on disk with the data
Returns:
NULL on error (i.e. invalid arguments, out of memory)

Definition at line 333 of file response.c.

References MHD_create_response_from_fd_at_offset().

Here is the call graph for this function:

struct MHD_Response* MHD_create_response_from_fd_at_offset ( size_t  size,
int  fd,
off_t  offset 
)

Create a response object. The response object can be extended with header information and then be used any number of times.

Parameters:
size size of the data portion of the response
fd file descriptor referring to a file on disk with the data
off offset to start reading from in the file
Returns:
NULL on error (i.e. invalid arguments, out of memory)

Definition at line 303 of file response.c.

References MHD_Response::crc_cls, MHD_Response::fd, MHD_Response::fd_off, file_reader(), free_callback(), MHD_create_response_from_callback(), and NULL.

Referenced by MHD_create_response_from_fd().

Here is the call graph for this function:

Here is the caller graph for this function:

int MHD_del_response_header ( struct MHD_Response response,
const char *  header,
const char *  content 
)

Delete a header line from the response.

Parameters:
response response to remove a header from
header the header to delete
content value to delete
Returns:
MHD_NO on error (no such header known)

Definition at line 129 of file response.c.

References MHD_Response::first_header, MHD_HTTP_Header::header, MHD_NO, MHD_YES, MHD_HTTP_Header::next, NULL, and MHD_HTTP_Header::value.

void MHD_destroy_response ( struct MHD_Response response  ) 

Destroy a response object and associated resources. Note that libmicrohttpd may keep some of the resources around if the response is still in the queue for some clients, so the memory may not necessarily be freed immediatley.

Definition at line 424 of file response.c.

References MHD_Response::crc_cls, MHD_Response::crfc, MHD_Response::first_header, MHD_HTTP_Header::header, MHD_Response::mutex, MHD_HTTP_Header::next, NULL, MHD_Response::reference_count, and MHD_HTTP_Header::value.

Referenced by MHD_cleanup_connections(), MHD_connection_handle_idle(), parse_connection_headers(), and transmit_error_response().

Here is the caller graph for this function:

const char* MHD_get_response_header ( struct MHD_Response response,
const char *  key 
)

Get a particular header from the response.

Parameters:
key which header to get
Returns:
NULL if header does not exist

Definition at line 195 of file response.c.

References MHD_Response::first_header, MHD_HTTP_Header::header, MHD_HTTP_Header::next, NULL, and MHD_HTTP_Header::value.

Referenced by add_extra_headers(), and build_header_response().

Here is the caller graph for this function:

int MHD_get_response_headers ( struct MHD_Response response,
MHD_KeyValueIterator  iterator,
void *  iterator_cls 
)

Get all of the headers added to a response.

Parameters:
iterator callback to call on each header; maybe NULL (then just count headers)
iterator_cls extra argument to iterator
Returns:
number of entries iterated over

Definition at line 169 of file response.c.

References MHD_Response::first_header, MHD_HTTP_Header::header, MHD_HTTP_Header::kind, MHD_YES, MHD_HTTP_Header::next, NULL, and MHD_HTTP_Header::value.

void MHD_increment_response_rc ( struct MHD_Response response  ) 

Increment response RC. Should this be part of the public API?

Definition at line 453 of file response.c.

References MHD_Response::mutex, and MHD_Response::reference_count.

Referenced by MHD_queue_response().

Here is the caller graph for this function:


Generated on Thu May 10 14:38:02 2012 for GNU libmicrohttpd by  doxygen 1.4.7