fixing 1399

This commit is contained in:
Christian Grothoff
2008-08-06 16:32:11 +00:00
parent ae588bb3c8
commit dfd057b9b6
3 changed files with 115 additions and 0 deletions
+30
View File
@@ -695,6 +695,36 @@ and returns the number of headers.
@end deftypefun
@deftypefun int MHD_set_connection_value (struct MHD_Connection *connection, enum MHD_ValueKind kind, const char * key, const char * value)
This function can be used to add an entry to
the HTTP headers of a connection (so that the
MHD_get_connection_values function will return
them -- and the MHD PostProcessor will also
see them). This maybe required in certain
situations (see Mantis #1399) where (broken)
HTTP implementations fail to supply values needed
by the post processor (or other parts of the
application).
This function MUST only be called from within
the MHD_AccessHandlerCallback (otherwise, access
maybe improperly synchronized). Furthermore,
the client must guarantee that the key and
value arguments are 0-terminated strings that
are NOT freed until the connection is closed.
(The easiest way to do this is by passing only
arguments to permanently allocated strings.).
@var{connection} is the connection for which
the entry for @var{key} of the given @var{kind}
should be set to the given @var{value}.
The function returns @code{MHD_NO} if the operation
could not be performed due to insufficient memory
and @code{MHD_YES} on success.
@end deftypefun
@deftypefun {const char *} MHD_lookup_connection_value (struct MHD_Connection *connection, enum MHD_ValueKind kind, const char *key)
Get a particular header value. If multiple values match the @var{kind},
return one of them (the ``first'', whatever that means). @var{key} must
+50
View File
@@ -147,6 +147,56 @@ MHD_get_connection_values (struct MHD_Connection *connection,
return ret;
}
/**
* This function can be used to add an entry to
* the HTTP headers of a connection (so that the
* MHD_get_connection_values function will return
* them -- and the MHD PostProcessor will also
* see them). This maybe required in certain
* situations (see Mantis #1399) where (broken)
* HTTP implementations fail to supply values needed
* by the post processor (or other parts of the
* application).
* <p>
* This function MUST only be called from within
* the MHD_AccessHandlerCallback (otherwise, access
* maybe improperly synchronized). Furthermore,
* the client must guarantee that the key and
* value arguments are 0-terminated strings that
* are NOT freed until the connection is closed.
* (The easiest way to do this is by passing only
* arguments to permanently allocated strings.).
*
* @param connection the connection for which a
* value should be set
* @param kind kind of the value
* @param key key for the value
* @param value the value itself
* @return MHD_NO if the operation could not be
* performed due to insufficient memory;
* MHD_YES on success
*/
int
MHD_set_connection_value (struct MHD_Connection *connection,
enum MHD_ValueKind kind,
const char *key,
const char *value)
{
struct MHD_HTTP_Header * pos;
pos = MHD_pool_allocate(connection->pool,
sizeof(struct MHD_HTTP_Header),
MHD_NO);
if (pos == NULL)
return MHD_NO;
pos->header = (char*) key;
pos->value = (char*) value;
pos->kind = kind;
pos->next = connection->headers_received;
connection->headers_received = pos;
return MHD_YES;
}
/**
* Get a particular header value. If multiple
* values match the kind, return any one of them.
+35
View File
@@ -790,6 +790,41 @@ MHD_get_connection_values (struct MHD_Connection *connection,
enum MHD_ValueKind kind,
MHD_KeyValueIterator iterator, void *iterator_cls);
/**
* This function can be used to add an entry to
* the HTTP headers of a connection (so that the
* MHD_get_connection_values function will return
* them -- and the MHD PostProcessor will also
* see them). This maybe required in certain
* situations (see Mantis #1399) where (broken)
* HTTP implementations fail to supply values needed
* by the post processor (or other parts of the
* application).
* <p>
* This function MUST only be called from within
* the MHD_AccessHandlerCallback (otherwise, access
* maybe improperly synchronized). Furthermore,
* the client must guarantee that the key and
* value arguments are 0-terminated strings that
* are NOT freed until the connection is closed.
* (The easiest way to do this is by passing only
* arguments to permanently allocated strings.).
*
* @param connection the connection for which a
* value should be set
* @param kind kind of the value
* @param key key for the value
* @param value the value itself
* @return MHD_NO if the operation could not be
* performed due to insufficient memory;
* MHD_YES on success
*/
int
MHD_set_connection_value (struct MHD_Connection *connection,
enum MHD_ValueKind kind,
const char *key,
const char *value);
/**
* Get a particular header value. If multiple
* values match the kind, return any one of them.