HTTP_SERVLET_REDIRECT(3)

NAME
http_servlet_redirect - HTTP redirect servlet

LIBRARY
PDEL Library (libpdel, -lpdel)

SYNOPSIS
#include <sys/types.h>
#include <stdio.h>
#include <netinet/in.h>
#include <openssl/ssl.h>
#include <pdel/http/http_defs.h>
#include <pdel/http/http_server.h>
#include <pdel/http/servlet/redirect.h>
struct http_servlet *
http_servlet_redirect_create(const char *url, int append_url);

DESCRIPTION
http_servlet_redirect_create() creates a new servlet that responds to all queries with an HTTP "302 Found" status code and supplies the new redirect URL url in the "Location" header. This causes the client to retry the transaction at the new URL.

The append_url argument determines whether and how the originally requested URL is included in the redirect URL and may equal one of the following:

HTTP_SERVLET_REDIRECT_NO_APPEND
    url is always returned unmodified; the originally requested URL is discarded.

HTTP_SERVLET_REDIRECT_APPEND_QUERY
    The query string component of the originally requested URL is appended to url as additional query string argument(s).

HTTP_SERVLET_REDIRECT_APPEND_URI
    This causes the path and query string components of the originally requested URL (i.e., the URI) to be appended to url, in effect mapping the original URL into the corresponding "subdirectory" of url.

HTTP_SERVLET_REDIRECT_APPEND_URL
    The originally requested URL is URL-encoded and appended as an additional query string argument to the redirect URL url. This is useful for example when redirecting to a login page that will redirect back to the originally requested URL after a successful login.

RETURN VALUES
On failure, http_servlet_redirect_create() returns NULL and sets errno to an appropriate value.

SEE ALSO
http_request(3), http_response(3), http_server(3), http_servlet(3), libpdel(3)

HISTORY
The PDEL library was developed at Packet Design, LLC. http://www.packetdesign.com/

AUTHORS
Archie Cobbs <archie@freebsd.org>