Manual Reference Pages - HTTP_RESPONSE (3)
- HTTP response object
PDEL Library (libpdel, -lpdel)
http_response_get_code struct http_response *resp
http_response_get_remote_ip struct http_response *resp
http_response_get_remote_port struct http_response *resp
http_response_get_ssl struct http_response *resp
http_response_num_headers struct http_response *req
const char *
http_response_get_header struct http_response *resp const char *name
http_response_get_header_by_index struct http_response *resp u_int index const char **namep const char **valuep
http_response_set_header struct http_response *resp int append const char *name const char *valfmt ...
http_response_remove_header struct http_response *resp const char *name
http_response_send_headers struct http_response *resp int unbuffer
http_response_get_input struct http_response *resp
http_response_get_output struct http_response *resp int buffer
http_response_send_redirect struct http_response *resp const char *url
http_response_send_basic_auth struct http_response *resp const char *realm
http_response_send_error struct http_response *resp int code const char *fmt ...
http_response_send_errno_error struct http_response *resp
http_response_guess_mime const char *path const char **ctype const char **cencs int maxenc
const char *
http_response_status_msg int code
http_response_no_body int code
http_response_get_raw_socket struct http_response *resp
object is used by the PDEL HTTP library to represent an HTTP response.
An HTTP response may be associated with an HTTP server (the response is
generated locally) or an HTTP client (the response is generated remotely).
Some of the functions and values defined below only make sense in one
of these cases.
objects are not created directly; rather, they are obtained from another
object which is associated with the HTTP connection.
They are freed automatically (and become invalid) when the corresponding
HTTP connection object is closed.
returns the HTTP status code from the response, e.g., 200 for "OK".
Status codes are defined in
which is included by
returns the IP address of the remote side.
returns the TCP port of the remote side.
returns the SSL context for the HTTP connection, or
if the connection is not over SSL.
returns the value of the named header, or
if the header is not defined for the response.
HTTP header names are case-insensitive.
returns the number of headers in the response.
at the name and
at the value of the header with index
which must be less than the value returned by
formats and sets a header value.
is non-zero, the value is appended to any existing value
(after adding a ", " separator) rather than replacing it.
As a special case, setting the "Set-Cookie" header does not
replace existing instances, it just adds a new instance.
When the response headers are sent, all instances of "Set-Cookie" are sent.
removes a header from the response.
causes the server response headers to be sent to the client if they
havent already been sent.
to non-zero causes the output to be unbuffered.
It has the same affect as setting
to zero when calling
returns the body of the response as an input stream.
The local side must be the client for this HTTP connection.
returns an output stream that writes into the body of the response.
The local side must be the server for this HTTP connection.
determines whether the entire output should be buffered before sending, or
should writes to the stream translate immediately into writes to the server.
The latter option will force the headers to be sent (if they havent been
sent already) when the first byte is written to the stream.
to zero is also incompatible with keep-alive, unless the user code manually
sets the "Content-Length" header (in which case it takes responsibility
for writing the correct number of bytes).
is non-zero, the output will be buffered entirely in memory until the output
stream is closed, at which point "Content-Length" is computed automatically.
Certain HTTP responses (e.g., "304 Not Modified") do not have an associated
response body (see
below); for these responses, the output stream returned by
will discard all data written to it.
sends an HTTP redirect (301) to the client.
is the URL to which the client should be redirected.
sends an "Unauthorized" repsonse (401) to the client, causing browsers
to pop up a login window.
Only "Basic" authentication is supported.
is the authentication realm (which is usually visible in the popup window).
formats and sends an error response to the client with the HTTP status code
For status codes that have response bodies, a very simple HTML page
is cobbled together and sent as well.
to use the generic error message that corresponds to
otherwise, the error string is formatted as with
attempts to generate an appropriate error response based on the value of
tries to guess the MIME "Content-Type" and "Content-Encoding" of the file
The content type is returned in
If it cant be determined, "text/plain; charset=iso-8859-1" is returned.
The content encoding is really a list of encodings.
For example, "foo.uu.gz" would be detected as having encoding
"x-uuencode" followed by "gzip".
argument should point to an array of
This array will be filled in and any extra entries set to
no attempt is made to determine content encoding.
returns an ASCII string corresponding to the HTTP response code
returns 1 if a response with HTTP response code
should not have a response body, otherwise zero.
returns the underlying file descriptor for the HTTP connection.
This is a huge layering violation fraught with danger.
This function will fail for SSL connections.
The returned file descriptor should not be closed.
All of the above routines that can return an error return
or -1 to indicate this and set
to an appropriate value.
Success is indicated by a normal return value or zero.
Hypertext Transfer Protocol -- HTTP/1.1
The PDEL library was developed at Packet Design, LLC.
.An Archie Cobbs Aq email@example.com
There are not as many
methods as there are
This reflects a bias of the library towards implementing servers
rather than clients.
More support for the client side should be added.
Visit the GSP FreeBSD Man Page Interface.
Output converted with manServer 1.07.