strongswan/src/libfast/fast_request.h

218 lines
5.3 KiB
C
Raw Normal View History

2007-09-11 15:22:02 +00:00
/*
* Copyright (C) 2007 Martin Willi
* HSR Hochschule fuer Technik Rapperswil
2007-09-11 15:22:02 +00:00
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*/
/**
* @defgroup fast_request fast_request
* @{ @ingroup libfast
2007-09-11 15:22:02 +00:00
*/
#ifndef FAST_REQUEST_H_
#define FAST_REQUEST_H_
2007-09-11 15:22:02 +00:00
#include <fcgiapp.h>
#include <library.h>
2007-09-11 15:22:02 +00:00
typedef struct fast_request_t fast_request_t;
2007-09-11 15:22:02 +00:00
/**
* A HTTP request, encapsulates FCGX_Request.
2007-09-11 15:22:02 +00:00
*
* The response is also handled through the request object.
2007-09-11 15:22:02 +00:00
*/
struct fast_request_t {
/**
* Add a cookie to the reply (Set-Cookie header).
*
* @param name name of the cookie to set
* @param value value of the cookie
*/
void (*add_cookie)(fast_request_t *this, char *name, char *value);
2007-09-11 15:22:02 +00:00
/**
* Get a cookie the client sent in the request.
2007-09-11 15:22:02 +00:00
*
* @param name name of the cookie
* @return cookie value, NULL if no such cookie found
*/
char* (*get_cookie)(fast_request_t *this, char *name);
2007-09-11 15:22:02 +00:00
/**
* Get the request path relative to the application.
2007-09-11 15:22:02 +00:00
*
* @return path
*/
char* (*get_path)(fast_request_t *this);
2007-09-11 15:22:02 +00:00
/**
* Get the base path of the application.
*
* @return base path
*/
char* (*get_base)(fast_request_t *this);
/**
* Get the remote host address of this request.
*
* @return host address as string
*/
char* (*get_host)(fast_request_t *this);
/**
* Get the user agent string.
*
* @return user agent string
*/
char* (*get_user_agent)(fast_request_t *this);
/**
* Get a post/get variable included in the request.
2007-09-11 15:22:02 +00:00
*
* @param name name of the POST/GET variable
2007-09-11 15:22:02 +00:00
* @return value, NULL if not found
*/
char* (*get_query_data)(fast_request_t *this, char *name);
/**
* Get an arbitrary environment variable.
*
* @param name name of the environment variable
* @return value, NULL if not found
*/
char* (*get_env_var)(fast_request_t *this, char *name);
/**
* Read raw POST/PUT data from HTTP request.
*
* @param buf buffer to read data into
* @param len size of the supplied buffer
* @return number of bytes read, < 0 on error
*/
int (*read_data)(fast_request_t *this, char *buf, int len);
/**
* Close the session and it's context after handling.
*/
void (*close_session)(fast_request_t *this);
/**
* Has the session been closed by close_session()?
*
* @return TRUE if session has been closed
*/
bool (*session_closed)(fast_request_t *this);
/**
* Redirect the client to another location.
*
* @param fmt location format string
* @param ... variable argument for fmt
*/
void (*redirect)(fast_request_t *this, char *fmt, ...);
2010-03-09 14:03:57 +00:00
/**
* Get the HTTP referer.
*
* @return HTTP referer
*/
char* (*get_referer)(fast_request_t *this);
2010-03-09 14:03:57 +00:00
/**
* Redirect back to the referer.
*/
void (*to_referer)(fast_request_t *this);
/**
* Set a template value.
*
* @param key key to set
* @param value value to set key to
*/
void (*set)(fast_request_t *this, char *key, char *value);
/**
* Set a template value using format strings.
*
* Format string is in the form "key=value", where printf like format
* substitution occurs over the whole string.
*
* @param format printf like format string
* @param ... variable argument list
*/
void (*setf)(fast_request_t *this, char *format, ...);
/**
* Render a template.
*
* The render() function additionally sets a HDF variable "base"
* which points to the root of the web application and allows to point to
* other targets without to worry about path location.
*
* @param template clearsilver template file location
*/
void (*render)(fast_request_t *this, char *template);
/**
* Stream a format string to the client.
*
* Stream is not closed and may be called multiple times to allow
* server-push functionality.
*
* @param format printf like format string
Spelling fixes * accumulating * acquire * alignment * appropriate * argument * assign * attribute * authenticate * authentication * authenticator * authority * auxiliary * brackets * callback * camellia * can't * cancelability * certificate * choinyambuu * chunk * collector * collision * communicating * compares * compatibility * compressed * confidentiality * configuration * connection * consistency * constraint * construction * constructor * database * decapsulated * declaration * decrypt * derivative * destination * destroyed * details * devised * dynamic * ecapsulation * encoded * encoding * encrypted * enforcing * enumerator * establishment * excluded * exclusively * exited * expecting * expire * extension * filter * firewall * foundation * fulfillment * gateways * hashing * hashtable * heartbeats * identifier * identifiers * identities * identity * implementers * indicating * initialize * initiate * initiation * initiator * inner * instantiate * legitimate * libraries * libstrongswan * logger * malloc * manager * manually * measurement * mechanism * message * network * nonexistent * object * occurrence * optional * outgoing * packages * packets * padding * particular * passphrase * payload * periodically * policies * possible * previously * priority * proposal * protocol * provide * provider * pseudo * pseudonym * public * qualifier * quantum * quintuplets * reached * reading * recommendation to * recommendation * recursive * reestablish * referencing * registered * rekeying * reliable * replacing * representing * represents * request * request * resolver * result * resulting * resynchronization * retriable * revocation * right * rollback * rule * rules * runtime * scenario * scheduled * security * segment * service * setting * signature * specific * specified * speed * started * steffen * strongswan * subjectaltname * supported * threadsafe * traffic * tremendously * treshold * unique * uniqueness * unknown * until * upper * using * validator * verification * version * version * warrior Closes strongswan/strongswan#164.
2020-02-05 04:30:52 +00:00
* @param ... argument list to format string
* @return number of streamed bytes, < 0 if stream closed
*/
int (*streamf)(fast_request_t *this, char *format, ...);
/**
* Serve a request with headers and a body.
*
* @param headers HTTP headers, \n separated
* @param chunk body to write to output
*/
void (*serve)(fast_request_t *this, char *headers, chunk_t chunk);
/**
* Send a file from the file system.
*
* @param path path to file to serve
* @param mime mime type of file to send, or NULL
* @return TRUE if file served successfully
*/
bool (*sendfile)(fast_request_t *this, char *path, char *mime);
2007-09-11 15:22:02 +00:00
/**
* Increase the reference count to the stream.
*
* @return this with increased refcount
*/
fast_request_t* (*get_ref)(fast_request_t *this);
/**
* Destroy the fast_request_t.
2007-09-11 15:22:02 +00:00
*/
void (*destroy) (fast_request_t *this);
2007-09-11 15:22:02 +00:00
};
/**
* Create a request from the fastcgi struct.
2007-09-11 15:22:02 +00:00
*
* @param fd file descripter opened with FCGX_OpenSocket
* @param debug no stripping, no compression, timing information
2007-09-11 15:22:02 +00:00
*/
fast_request_t *fast_request_create(int fd, bool debug);
2007-09-11 15:22:02 +00:00
#endif /** REQUEST_H_ @}*/