mirror of
https://git.gnunet.org/libmicrohttpd.git
synced 2026-09-25 04:09:31 +03:00
footer support
This commit is contained in:
@@ -1,3 +1,6 @@
|
||||
Sun Nov 14 20:45:45 CET 2010
|
||||
Adding API call to generate HTTP footers in response. -CG
|
||||
|
||||
Sat Oct 16 12:38:43 CEST 2010
|
||||
Releasing libmicrohttpd 0.9.2. -CG
|
||||
|
||||
|
||||
+19
-1
@@ -1327,8 +1327,26 @@ memory allocation error).
|
||||
@end deftypefun
|
||||
|
||||
|
||||
@deftypefun int MHD_add_response_footer (struct MHD_Response *response, const char *footer, const char *content)
|
||||
Add a footer line to the response. The strings referenced by
|
||||
@var{footer} and @var{content} must be zero-terminated and they are
|
||||
duplicated into memory blocks embedded in @var{response}.
|
||||
|
||||
Notice that the strings must not hold newlines, carriage returns or tab
|
||||
chars. You can add response footers at any time before signalling the
|
||||
end of the response to MHD (not just before calling 'MHD_queue_response').
|
||||
Footers are useful for adding cryptographic checksums to the reply or to
|
||||
signal errors encountered during data generation. This call was introduced
|
||||
in MHD 0.9.3.
|
||||
|
||||
Return @code{MHD_NO} on error (i.e. invalid header or content format or
|
||||
memory allocation error).
|
||||
@end deftypefun
|
||||
|
||||
|
||||
|
||||
@deftypefun int MHD_del_response_header (struct MHD_Response *response, const char *header, const char *content)
|
||||
Delete a header line from the response. Return @code{MHD_NO} on error
|
||||
Delete a header (or footer) line from the response. Return @code{MHD_NO} on error
|
||||
(arguments are invalid or no such header known).
|
||||
@end deftypefun
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@ MHD_create_response_from_data
|
||||
MHD_create_response_from_fd
|
||||
MHD_destroy_response
|
||||
MHD_add_response_header
|
||||
MHD_add_response_footer
|
||||
MHD_del_response_header
|
||||
MHD_get_response_headers
|
||||
MHD_get_response_header
|
||||
|
||||
+55
-5
@@ -27,14 +27,21 @@
|
||||
#include "internal.h"
|
||||
#include "response.h"
|
||||
|
||||
|
||||
/**
|
||||
* Add a header line to the response.
|
||||
* Add a header or footer line to the response.
|
||||
*
|
||||
* @param response response to add a header to
|
||||
* @param kind header or footer
|
||||
* @param header the header to add
|
||||
* @param content value to add
|
||||
* @return MHD_NO on error (i.e. invalid header or content format).
|
||||
*/
|
||||
int
|
||||
MHD_add_response_header (struct MHD_Response *response,
|
||||
const char *header, const char *content)
|
||||
static int
|
||||
add_response_entry (struct MHD_Response *response,
|
||||
enum MHD_ValueKind kind,
|
||||
const char *header,
|
||||
const char *content)
|
||||
{
|
||||
struct MHD_HTTP_Header *hdr;
|
||||
|
||||
@@ -65,15 +72,57 @@ MHD_add_response_header (struct MHD_Response *response,
|
||||
free (hdr);
|
||||
return MHD_NO;
|
||||
}
|
||||
hdr->kind = MHD_HEADER_KIND;
|
||||
hdr->kind = kind;
|
||||
hdr->next = response->first_header;
|
||||
response->first_header = hdr;
|
||||
return MHD_YES;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Add a header line to the response.
|
||||
*
|
||||
* @param response response to add a header to
|
||||
* @param header the header to add
|
||||
* @param content value to add
|
||||
* @return MHD_NO on error (i.e. invalid header or content format).
|
||||
*/
|
||||
int
|
||||
MHD_add_response_header (struct MHD_Response *response,
|
||||
const char *header, const char *content)
|
||||
{
|
||||
return add_response_entry (response,
|
||||
MHD_HEADER_KIND,
|
||||
header,
|
||||
content);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Add a footer line to the response.
|
||||
*
|
||||
* @param response response to remove a header from
|
||||
* @param footer the footer to delete
|
||||
* @param content value to delete
|
||||
* @return MHD_NO on error (i.e. invalid footer or content format).
|
||||
*/
|
||||
int
|
||||
MHD_add_response_footer (struct MHD_Response *response,
|
||||
const char *footer, const char *content)
|
||||
{
|
||||
return add_response_entry (response,
|
||||
MHD_FOOTER_KIND,
|
||||
header,
|
||||
content);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Delete a header line from the response.
|
||||
*
|
||||
* @param response response to remove a header from
|
||||
* @param header the header to delete
|
||||
* @param content value to delete
|
||||
* @return MHD_NO on error (no such header known)
|
||||
*/
|
||||
int
|
||||
@@ -107,6 +156,7 @@ MHD_del_response_header (struct MHD_Response *response,
|
||||
return MHD_NO;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get all of the headers added to a response.
|
||||
*
|
||||
|
||||
@@ -106,7 +106,7 @@ extern "C"
|
||||
/**
|
||||
* Current version of the library.
|
||||
*/
|
||||
#define MHD_VERSION 0x00090200
|
||||
#define MHD_VERSION 0x00090201
|
||||
|
||||
/**
|
||||
* MHD-internal return code for "YES".
|
||||
@@ -1194,8 +1194,22 @@ int
|
||||
MHD_add_response_header (struct MHD_Response *response,
|
||||
const char *header, const char *content);
|
||||
|
||||
|
||||
/**
|
||||
* Delete a header line from the response.
|
||||
* Add a footer line to the response.
|
||||
*
|
||||
* @param response response to remove a header from
|
||||
* @param footer the footer to delete
|
||||
* @param content value to delete
|
||||
* @return MHD_NO on error (i.e. invalid footer or content format).
|
||||
*/
|
||||
int
|
||||
MHD_add_response_footer (struct MHD_Response *response,
|
||||
const char *footer, const char *content);
|
||||
|
||||
|
||||
/**
|
||||
* Delete a header (or footer) line from the response.
|
||||
*
|
||||
* @param response response to remove a header from
|
||||
* @param header the header to delete
|
||||
@@ -1207,7 +1221,7 @@ MHD_del_response_header (struct MHD_Response *response,
|
||||
const char *header, const char *content);
|
||||
|
||||
/**
|
||||
* Get all of the headers added to a response.
|
||||
* Get all of the headers (and footers) added to a response.
|
||||
*
|
||||
* @param response response to query
|
||||
* @param iterator callback to call on each header;
|
||||
@@ -1221,7 +1235,7 @@ MHD_get_response_headers (struct MHD_Response *response,
|
||||
|
||||
|
||||
/**
|
||||
* Get a particular header from the response.
|
||||
* Get a particular header (or footer) from the response.
|
||||
*
|
||||
* @param response response to query
|
||||
* @param key which header to get
|
||||
|
||||
Reference in New Issue
Block a user