libonion
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Macros | Functions
response.c File Reference
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <stdio.h>
#include <time.h>
#include <stdarg.h>
#include <assert.h>
#include "dict.h"
#include "request.h"
#include "response.h"
#include "types_internal.h"
#include "log.h"
#include "codecs.h"
#include "low.h"

Macros

#define CONNECTION_CLOSE   "Connection: Close\r\n"
#define CONNECTION_KEEP_ALIVE   "Connection: Keep-Alive\r\n"
#define CONNECTION_CHUNK_ENCODING   "Transfer-Encoding: chunked\r\n"
#define CONNECTION_UPGRADE   "Connection: Upgrade\r\n"

Functions

const char * onion_response_code_description (int code)
int onion_response_flush (onion_response *res)
 Writes all buffered output waiting for sending.If header has not been sent yet (delayed), it uses a temporary buffer to send it now. This way header can use the buffer_size information to send the proper content-length, even when it wasnt properly set by programmer. Whith this information its possib to keep alive the connection on more cases.
ssize_t onion_response_write0 (onion_response *res, const char *data)
 Writes some data to the response. \0 ended string.
ssize_t onion_response_write_html_safe (onion_response *res, const char *data)
 Writes the given string to the res, but encodes the data using html entitiesThe encoding mens that <html> whould become <html>
onion_dictonion_response_get_headers (onion_response *res)
 Returns the headers dictionary, so user can add repeated headersOnly simple use case is to add several coockies; using normal set_header is not possible, but accessing the dictionary user can add repeated headers without problem.
void onion_response_add_cookie (onion_response *res, const char *cookiename, const char *cookievalue, time_t validity_t, const char *path, const char *domain, int flags)
 Sets a new cookie into the response.

Macro Definition Documentation

#define CONNECTION_CHUNK_ENCODING   "Transfer-Encoding: chunked\r\n"
#define CONNECTION_CLOSE   "Connection: Close\r\n"
#define CONNECTION_KEEP_ALIVE   "Connection: Keep-Alive\r\n"
#define CONNECTION_UPGRADE   "Connection: Upgrade\r\n"

Function Documentation

const char* onion_response_code_description ( int  code)