GNU libmicrohttpd  0.9.29
microspdy.h File Reference

public interface to libmicrospdy More...

#include <zlib.h>
#include <stdbool.h>
#include <unistd.h>
#include <stdarg.h>
#include <stdint.h>
#include <sys/time.h>
#include <sys/types.h>
#include <sys/socket.h>
Include dependency graph for microspdy.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define _MHD_EXTERN   extern
 
#define SPDY_YES   1
 
#define SPDY_NO   0
 
#define SPDY_INPUT_ERROR   -1
 
#define SPDY_VERSION   3
 
#define SPDY_MAX_SUPPORTED_FRAME_SIZE   8192
 
#define SPDY_HTTP_CONTINUE   100
 
#define SPDY_HTTP_SWITCHING_PROTOCOLS   101
 
#define SPDY_HTTP_PROCESSING   102
 
#define SPDY_HTTP_OK   200
 
#define SPDY_HTTP_CREATED   201
 
#define SPDY_HTTP_ACCEPTED   202
 
#define SPDY_HTTP_NON_AUTHORITATIVE_INFORMATION   203
 
#define SPDY_HTTP_NO_CONTENT   204
 
#define SPDY_HTTP_RESET_CONTENT   205
 
#define SPDY_HTTP_PARTIAL_CONTENT   206
 
#define SPDY_HTTP_MULTI_STATUS   207
 
#define SPDY_HTTP_MULTIPLE_CHOICES   300
 
#define SPDY_HTTP_MOVED_PERMANENTLY   301
 
#define SPDY_HTTP_FOUND   302
 
#define SPDY_HTTP_SEE_OTHER   303
 
#define SPDY_HTTP_NOT_MODIFIED   304
 
#define SPDY_HTTP_USE_PROXY   305
 
#define SPDY_HTTP_SWITCH_PROXY   306
 
#define SPDY_HTTP_TEMPORARY_REDIRECT   307
 
#define SPDY_HTTP_BAD_REQUEST   400
 
#define SPDY_HTTP_UNAUTHORIZED   401
 
#define SPDY_HTTP_PAYMENT_REQUIRED   402
 
#define SPDY_HTTP_FORBIDDEN   403
 
#define SPDY_HTTP_NOT_FOUND   404
 
#define SPDY_HTTP_METHOD_NOT_ALLOWED   405
 
#define SPDY_HTTP_METHOD_NOT_ACCEPTABLE   406
 
#define SPDY_HTTP_PROXY_AUTHENTICATION_REQUIRED   407
 
#define SPDY_HTTP_REQUEST_TIMEOUT   408
 
#define SPDY_HTTP_CONFLICT   409
 
#define SPDY_HTTP_GONE   410
 
#define SPDY_HTTP_LENGTH_REQUIRED   411
 
#define SPDY_HTTP_PRECONDITION_FAILED   412
 
#define SPDY_HTTP_REQUEST_ENTITY_TOO_LARGE   413
 
#define SPDY_HTTP_REQUEST_URI_TOO_LONG   414
 
#define SPDY_HTTP_UNSUPPORTED_MEDIA_TYPE   415
 
#define SPDY_HTTP_REQUESTED_RANGE_NOT_SATISFIABLE   416
 
#define SPDY_HTTP_EXPECTATION_FAILED   417
 
#define SPDY_HTTP_UNPROCESSABLE_ENTITY   422
 
#define SPDY_HTTP_LOCKED   423
 
#define SPDY_HTTP_FAILED_DEPENDENCY   424
 
#define SPDY_HTTP_UNORDERED_COLLECTION   425
 
#define SPDY_HTTP_UPGRADE_REQUIRED   426
 
#define SPDY_HTTP_NO_RESPONSE   444
 
#define SPDY_HTTP_RETRY_WITH   449
 
#define SPDY_HTTP_BLOCKED_BY_WINDOWS_PARENTAL_CONTROLS   450
 
#define SPDY_HTTP_UNAVAILABLE_FOR_LEGAL_REASONS   451
 
#define SPDY_HTTP_INTERNAL_SERVER_ERROR   500
 
#define SPDY_HTTP_NOT_IMPLEMENTED   501
 
#define SPDY_HTTP_BAD_GATEWAY   502
 
#define SPDY_HTTP_SERVICE_UNAVAILABLE   503
 
#define SPDY_HTTP_GATEWAY_TIMEOUT   504
 
#define SPDY_HTTP_HTTP_VERSION_NOT_SUPPORTED   505
 
#define SPDY_HTTP_VARIANT_ALSO_NEGOTIATES   506
 
#define SPDY_HTTP_INSUFFICIENT_STORAGE   507
 
#define SPDY_HTTP_BANDWIDTH_LIMIT_EXCEEDED   509
 
#define SPDY_HTTP_NOT_EXTENDED   510
 
#define SPDY_HTTP_HEADER_ACCEPT   "accept"
 
#define SPDY_HTTP_HEADER_ACCEPT_CHARSET   "accept-charset"
 
#define SPDY_HTTP_HEADER_ACCEPT_ENCODING   "accept-encoding"
 
#define SPDY_HTTP_HEADER_ACCEPT_LANGUAGE   "accept-language"
 
#define SPDY_HTTP_HEADER_ACCEPT_RANGES   "accept-ranges"
 
#define SPDY_HTTP_HEADER_AGE   "age"
 
#define SPDY_HTTP_HEADER_ALLOW   "allow"
 
#define SPDY_HTTP_HEADER_AUTHORIZATION   "authorization"
 
#define SPDY_HTTP_HEADER_CACHE_CONTROL   "cache-control"
 
#define SPDY_HTTP_HEADER_CONNECTION   "connection"
 
#define SPDY_HTTP_HEADER_CONTENT_ENCODING   "content-encoding"
 
#define SPDY_HTTP_HEADER_CONTENT_LANGUAGE   "content-language"
 
#define SPDY_HTTP_HEADER_CONTENT_LENGTH   "content-length"
 
#define SPDY_HTTP_HEADER_CONTENT_LOCATION   "content-location"
 
#define SPDY_HTTP_HEADER_CONTENT_MD5   "content-md5"
 
#define SPDY_HTTP_HEADER_CONTENT_RANGE   "content-range"
 
#define SPDY_HTTP_HEADER_CONTENT_TYPE   "content-type"
 
#define SPDY_HTTP_HEADER_COOKIE   "cookie"
 
#define SPDY_HTTP_HEADER_DATE   "date"
 
#define SPDY_HTTP_HEADER_ETAG   "etag"
 
#define SPDY_HTTP_HEADER_EXPECT   "expect"
 
#define SPDY_HTTP_HEADER_EXPIRES   "expires"
 
#define SPDY_HTTP_HEADER_FROM   "from"
 
#define SPDY_HTTP_HEADER_HOST   "host"
 
#define SPDY_HTTP_HEADER_IF_MATCH   "if-match"
 
#define SPDY_HTTP_HEADER_IF_MODIFIED_SINCE   "if-modified-since"
 
#define SPDY_HTTP_HEADER_IF_NONE_MATCH   "if-none-match"
 
#define SPDY_HTTP_HEADER_IF_RANGE   "if-range"
 
#define SPDY_HTTP_HEADER_IF_UNMODIFIED_SINCE   "if-unmodified-since"
 
#define SPDY_HTTP_HEADER_KEEP_ALIVE   "keep-alive"
 
#define SPDY_HTTP_HEADER_LAST_MODIFIED   "last-modified"
 
#define SPDY_HTTP_HEADER_LOCATION   "location"
 
#define SPDY_HTTP_HEADER_MAX_FORWARDS   "max-forwards"
 
#define SPDY_HTTP_HEADER_PRAGMA   "pragma"
 
#define SPDY_HTTP_HEADER_PROXY_AUTHENTICATE   "proxy-authenticate"
 
#define SPDY_HTTP_HEADER_PROXY_AUTHORIZATION   "proxy-authorization"
 
#define SPDY_HTTP_HEADER_PROXY_CONNECTION   "proxy-connection"
 
#define SPDY_HTTP_HEADER_RANGE   "range"
 
#define SPDY_HTTP_HEADER_REFERER   "referer"
 
#define SPDY_HTTP_HEADER_RETRY_AFTER   "retry-after"
 
#define SPDY_HTTP_HEADER_SERVER   "server"
 
#define SPDY_HTTP_HEADER_SET_COOKIE   "set-cookie"
 
#define SPDY_HTTP_HEADER_SET_COOKIE2   "set-cookie2"
 
#define SPDY_HTTP_HEADER_TE   "te"
 
#define SPDY_HTTP_HEADER_TRAILER   "trailer"
 
#define SPDY_HTTP_HEADER_TRANSFER_ENCODING   "transfer-encoding"
 
#define SPDY_HTTP_HEADER_UPGRADE   "upgrade"
 
#define SPDY_HTTP_HEADER_USER_AGENT   "user-agent"
 
#define SPDY_HTTP_HEADER_VARY   "vary"
 
#define SPDY_HTTP_HEADER_VIA   "via"
 
#define SPDY_HTTP_HEADER_WARNING   "warning"
 
#define SPDY_HTTP_HEADER_WWW_AUTHENTICATE   "www-authenticate"
 
#define SPDY_HTTP_VERSION_1_0   "HTTP/1.0"
 
#define SPDY_HTTP_VERSION_1_1   "HTTP/1.1"
 
#define SPDY_HTTP_METHOD_CONNECT   "CONNECT"
 
#define SPDY_HTTP_METHOD_DELETE   "DELETE"
 
#define SPDY_HTTP_METHOD_GET   "GET"
 
#define SPDY_HTTP_METHOD_HEAD   "HEAD"
 
#define SPDY_HTTP_METHOD_OPTIONS   "OPTIONS"
 
#define SPDY_HTTP_METHOD_POST   "POST"
 
#define SPDY_HTTP_METHOD_PUT   "PUT"
 
#define SPDY_HTTP_METHOD_TRACE   "TRACE"
 
#define SPDY_HTTP_POST_ENCODING_FORM_URLENCODED   "application/x-www-form-urlencoded"
 
#define SPDY_HTTP_POST_ENCODING_MULTIPART_FORMDATA   "multipart/form-data"
 
#define SPDY_init()   SPDY_init (SPDY_IO_SUBSYSTEM_OPENSSL)
 

Typedefs

typedef void(* SPDY_PanicCallback) (void *cls, const char *file, unsigned int line, const char *reason)
 
typedef void(* SPDY_NewSessionCallback) (void *cls, struct SPDY_Session *session)
 
typedef void(* SPDY_SessionClosedCallback) (void *cls, struct SPDY_Session *session, int by_client)
 
typedef int(* SPDY_NameValueIterator) (void *cls, const char *name, const char *const *value, int num_values)
 
typedef void(* SPDY_NewRequestCallback) (void *cls, struct SPDY_Request *request, uint8_t priority, const char *method, const char *path, const char *version, const char *host, const char *scheme, struct SPDY_NameValue *headers, bool more)
 
typedef int(* SPDY_NewDataCallback) (void *cls, struct SPDY_Request *request, const void *buf, size_t size, bool more)
 
typedef ssize_t(* SPDY_ResponseCallback) (void *cls, void *buffer, size_t max, bool *more)
 
typedef void(* SPDY_ResponseResultCallback) (void *cls, struct SPDY_Response *response, struct SPDY_Request *request, enum SPDY_RESPONSE_RESULT status, bool streamopened)
 
typedef void(* SPDY_PingCallback) (void *cls, struct SPDY_Session *session, struct timeval *rtt)
 
typedef int(* SPDY_SettingsIterator) (void *cls, enum SPDY_SETTINGS id, int32_t value, uint8_t flags)
 
typedef void(* SPDY_SettingsReceivedCallback) (struct SPDY_Session *session, struct SPDY_Settings *settings, uint8_t flags,...)
 

Enumerations

enum  SPDY_IO_SUBSYSTEM { SPDY_IO_SUBSYSTEM_NONE = 0, SPDY_IO_SUBSYSTEM_OPENSSL = 1, SPDY_IO_SUBSYSTEM_RAW = 2 }
 
enum  SPDY_DAEMON_OPTION {
  SPDY_DAEMON_OPTION_END = 0, SPDY_DAEMON_OPTION_SESSION_TIMEOUT = 1, SPDY_DAEMON_OPTION_SOCK_ADDR = 2, SPDY_DAEMON_OPTION_FLAGS = 4,
  SPDY_DAEMON_OPTION_IO_SUBSYSTEM = 8, SPDY_DAEMON_OPTION_MAX_NUM_FRAMES = 16
}
 
enum  SPDY_DAEMON_FLAG { SPDY_DAEMON_FLAG_NO = 0, SPDY_DAEMON_FLAG_ONLY_IPV6 = 1, SPDY_DAEMON_FLAG_NO_DELAY = 2 }
 
enum  SPDY_SETTINGS {
  SPDY_SETTINGS_UPLOAD_BANDWIDTH = 1, SPDY_SETTINGS_DOWNLOAD_BANDWIDTH = 2, SPDY_SETTINGS_ROUND_TRIP_TIME = 3, SPDY_SETTINGS_MAX_CONCURRENT_STREAMS = 4,
  SPDY_SETTINGS_CURRENT_CWND = 5, SPDY_SETTINGS_DOWNLOAD_RETRANS_RATE = 6, SPDY_SETTINGS_INITIAL_WINDOW_SIZE = 7, SPDY_SETTINGS_CLIENT_CERTIFICATE_VECTOR_SIZE = 8
}
 
enum  SPDY_FLAG_SETTINGS { SPDY_FLAG_SETTINGS_PERSIST_VALUE = 1, SPDY_FLAG_SETTINGS_PERSISTED = 2 }
 
enum  SPDY_FLAG_SETTINGS_FRAME { SPDY_FLAG_SETTINGS_CLEAR_SETTINGS = 1 }
 
enum  SPDY_SETTINGS_OPTION { SPDY_SETTINGS_OPTION_END = 0 }
 
enum  SPDY_RESPONSE_RESULT { SPDY_RESPONSE_RESULT_SUCCESS = 0, SPDY_RESPONSE_RESULT_SESSION_CLOSED = 1, SPDY_RESPONSE_RESULT_STREAM_CLOSED = 2 }
 

Functions

_MHD_EXTERN int() SPDY_init (enum SPDY_IO_SUBSYSTEM io_subsystem,...)
 
_MHD_EXTERN void SPDY_deinit (void)
 
_MHD_EXTERN void SPDY_set_panic_func (SPDY_PanicCallback cb, void *cls)
 
_MHD_EXTERN struct SPDY_DaemonSPDY_start_daemon (uint16_t port, const char *certfile, const char *keyfile, SPDY_NewSessionCallback nscb, SPDY_SessionClosedCallback sccb, SPDY_NewRequestCallback nrcb, SPDY_NewDataCallback npdcb, void *cls,...)
 
_MHD_EXTERN void SPDY_stop_daemon (struct SPDY_Daemon *daemon)
 
_MHD_EXTERN int SPDY_get_fdset (struct SPDY_Daemon *daemon, fd_set *read_fd_set, fd_set *write_fd_set, fd_set *except_fd_set)
 
_MHD_EXTERN int SPDY_get_timeout (struct SPDY_Daemon *daemon, unsigned long long *timeout)
 
_MHD_EXTERN void SPDY_run (struct SPDY_Daemon *daemon)
 
_MHD_EXTERN void SPDY_close_session (struct SPDY_Session *session)
 
_MHD_EXTERN void SPDY_set_cls_to_session (struct SPDY_Session *session, void *cls)
 
_MHD_EXTERN void * SPDY_get_cls_from_session (struct SPDY_Session *session)
 
_MHD_EXTERN socklen_t SPDY_get_remote_addr (struct SPDY_Session *session, struct sockaddr **addr)
 
_MHD_EXTERN struct SPDY_NameValueSPDY_name_value_create (void)
 
_MHD_EXTERN int SPDY_name_value_add (struct SPDY_NameValue *container, const char *name, const char *value)
 
_MHD_EXTERN const char *const * SPDY_name_value_lookup (struct SPDY_NameValue *container, const char *name, int *num_values)
 
_MHD_EXTERN int SPDY_name_value_iterate (struct SPDY_NameValue *container, SPDY_NameValueIterator iterator, void *iterator_cls)
 
_MHD_EXTERN void SPDY_name_value_destroy (struct SPDY_NameValue *container)
 
_MHD_EXTERN struct SPDY_SessionSPDY_get_session_for_request (const struct SPDY_Request *request)
 
_MHD_EXTERN void SPDY_set_cls_to_request (struct SPDY_Request *request, void *cls)
 
_MHD_EXTERN void * SPDY_get_cls_from_request (struct SPDY_Request *request)
 
_MHD_EXTERN struct SPDY_ResponseSPDY_build_response (int status, const char *statustext, const char *version, struct SPDY_NameValue *headers, const void *data, size_t size)
 
_MHD_EXTERN struct SPDY_ResponseSPDY_build_response_with_callback (int status, const char *statustext, const char *version, struct SPDY_NameValue *headers, SPDY_ResponseCallback rcb, void *rcb_cls, uint32_t block_size)
 
_MHD_EXTERN int SPDY_queue_response (struct SPDY_Request *request, struct SPDY_Response *response, bool closestream, bool consider_priority, SPDY_ResponseResultCallback rrcb, void *rrcb_cls)
 
_MHD_EXTERN void SPDY_destroy_response (struct SPDY_Response *response)
 
_MHD_EXTERN const struct SPDY_Settings * SPDY_settings_create (void)
 
_MHD_EXTERN int SPDY_settings_add (struct SPDY_Settings *container, enum SPDY_SETTINGS id, enum SPDY_FLAG_SETTINGS flags, int32_t value)
 
_MHD_EXTERN int SPDY_settings_lookup (const struct SPDY_Settings *container, enum SPDY_SETTINGS id, enum SPDY_FLAG_SETTINGS *flags, int32_t *value)
 
_MHD_EXTERN int SPDY_settings_iterate (const struct SPDY_Settings *container, SPDY_SettingsIterator iterator, void *iterator_cls)
 
_MHD_EXTERN void SPDY_settings_destroy (struct SPDY_Settings *container)
 
_MHD_EXTERN int SPDY_send_settings (struct SPDY_Session *session, struct SPDY_Settings *settings, enum SPDY_FLAG_SETTINGS_FRAME flags,...)
 
_MHD_EXTERN void SPDY_destroy_request (struct SPDY_Request *request)
 
_MHD_EXTERN int SPDY_send_ping (struct SPDY_Session *session, SPDY_PingCallback rttcb, void *rttcb_cls)
 

Detailed Description

public interface to libmicrospdy

Author
Andrey Uzunov
Christian Grothoff

All symbols defined in this header start with SPDY_. libmisrospdy is a small SPDY daemon library. The application can start multiple daemons and they are independent.

The header file defines various constants used by the SPDY and the HTTP protocol. This does not mean that the lib actually interprets all of these values. Not everything is implemented. The provided constants are exported as a convenience for users of the library. The lib does not verify that provided HTTP headers and if their values conform to the SPDY protocol, it only checks if the required headers for the SPDY requests and responses are provided.

The library uses just a single thread.

Before including "microspdy.h" you should add the necessary includes to define the types used in this file (which headers are needed may depend on your platform; for possible suggestions consult "platform.h" in the libmicrospdy distribution).

All of the functions returning SPDY_YES/SPDY_NO return SPDY_INPUT_ERROR when any of the parameters are invalid, e.g. required parameter is NULL.

The library does not check if anything at the application layer – requests and responses – is correct. For example, it is up to the user to check if a client is sending HTTP body but the method is GET.

The SPDY flow control is just partially implemented: the receiving window is updated, and the client is notified, to prevent a client from stop sending POST body data, for example.

Definition in file microspdy.h.

Macro Definition Documentation

#define _MHD_EXTERN   extern

Definition at line 87 of file microspdy.h.

#define SPDY_HTTP_ACCEPTED   202

Definition at line 128 of file microspdy.h.

#define SPDY_HTTP_BAD_GATEWAY   502

Definition at line 174 of file microspdy.h.

Referenced by run().

#define SPDY_HTTP_BAD_REQUEST   400

Definition at line 144 of file microspdy.h.

#define SPDY_HTTP_BANDWIDTH_LIMIT_EXCEEDED   509

Definition at line 180 of file microspdy.h.

#define SPDY_HTTP_BLOCKED_BY_WINDOWS_PARENTAL_CONTROLS   450

Definition at line 169 of file microspdy.h.

#define SPDY_HTTP_CONFLICT   409

Definition at line 153 of file microspdy.h.

#define SPDY_HTTP_CONTINUE   100

HTTP response codes.

Definition at line 122 of file microspdy.h.

#define SPDY_HTTP_CREATED   201

Definition at line 127 of file microspdy.h.

#define SPDY_HTTP_EXPECTATION_FAILED   417

Definition at line 161 of file microspdy.h.

#define SPDY_HTTP_FAILED_DEPENDENCY   424

Definition at line 164 of file microspdy.h.

#define SPDY_HTTP_FORBIDDEN   403

Definition at line 147 of file microspdy.h.

#define SPDY_HTTP_FOUND   302

Definition at line 137 of file microspdy.h.

#define SPDY_HTTP_GATEWAY_TIMEOUT   504

Definition at line 176 of file microspdy.h.

#define SPDY_HTTP_GONE   410

Definition at line 154 of file microspdy.h.

#define SPDY_HTTP_HEADER_ACCEPT   "accept"

HTTP headers are used in SPDY, but all of them MUST be lowercase. Some are not valid in SPDY and MUST not be used

Definition at line 187 of file microspdy.h.

#define SPDY_HTTP_HEADER_ACCEPT_CHARSET   "accept-charset"

Definition at line 188 of file microspdy.h.

#define SPDY_HTTP_HEADER_ACCEPT_ENCODING   "accept-encoding"

Definition at line 189 of file microspdy.h.

#define SPDY_HTTP_HEADER_ACCEPT_LANGUAGE   "accept-language"

Definition at line 190 of file microspdy.h.

#define SPDY_HTTP_HEADER_ACCEPT_RANGES   "accept-ranges"

Definition at line 191 of file microspdy.h.

#define SPDY_HTTP_HEADER_AGE   "age"

Definition at line 192 of file microspdy.h.

#define SPDY_HTTP_HEADER_ALLOW   "allow"

Definition at line 193 of file microspdy.h.

#define SPDY_HTTP_HEADER_AUTHORIZATION   "authorization"

Definition at line 194 of file microspdy.h.

#define SPDY_HTTP_HEADER_CACHE_CONTROL   "cache-control"

Definition at line 195 of file microspdy.h.

#define SPDY_HTTP_HEADER_CONNECTION   "connection"

Definition at line 197 of file microspdy.h.

Referenced by curl_header_cb().

#define SPDY_HTTP_HEADER_CONTENT_ENCODING   "content-encoding"

Definition at line 198 of file microspdy.h.

#define SPDY_HTTP_HEADER_CONTENT_LANGUAGE   "content-language"

Definition at line 199 of file microspdy.h.

#define SPDY_HTTP_HEADER_CONTENT_LENGTH   "content-length"

Definition at line 200 of file microspdy.h.

#define SPDY_HTTP_HEADER_CONTENT_LOCATION   "content-location"

Definition at line 201 of file microspdy.h.

#define SPDY_HTTP_HEADER_CONTENT_MD5   "content-md5"

Definition at line 202 of file microspdy.h.

#define SPDY_HTTP_HEADER_CONTENT_RANGE   "content-range"

Definition at line 203 of file microspdy.h.

#define SPDY_HTTP_HEADER_CONTENT_TYPE   "content-type"

Definition at line 204 of file microspdy.h.

#define SPDY_HTTP_HEADER_COOKIE   "cookie"

Definition at line 205 of file microspdy.h.

#define SPDY_HTTP_HEADER_DATE   "date"

Definition at line 206 of file microspdy.h.

#define SPDY_HTTP_HEADER_ETAG   "etag"

Definition at line 207 of file microspdy.h.

#define SPDY_HTTP_HEADER_EXPECT   "expect"

Definition at line 208 of file microspdy.h.

#define SPDY_HTTP_HEADER_EXPIRES   "expires"

Definition at line 209 of file microspdy.h.

#define SPDY_HTTP_HEADER_FROM   "from"

Definition at line 210 of file microspdy.h.

#define SPDY_HTTP_HEADER_HOST   "host"

Definition at line 212 of file microspdy.h.

#define SPDY_HTTP_HEADER_IF_MATCH   "if-match"

Definition at line 213 of file microspdy.h.

#define SPDY_HTTP_HEADER_IF_MODIFIED_SINCE   "if-modified-since"

Definition at line 214 of file microspdy.h.

#define SPDY_HTTP_HEADER_IF_NONE_MATCH   "if-none-match"

Definition at line 215 of file microspdy.h.

#define SPDY_HTTP_HEADER_IF_RANGE   "if-range"

Definition at line 216 of file microspdy.h.

#define SPDY_HTTP_HEADER_IF_UNMODIFIED_SINCE   "if-unmodified-since"

Definition at line 217 of file microspdy.h.

#define SPDY_HTTP_HEADER_KEEP_ALIVE   "keep-alive"

Definition at line 219 of file microspdy.h.

Referenced by curl_header_cb().

#define SPDY_HTTP_HEADER_LAST_MODIFIED   "last-modified"

Definition at line 220 of file microspdy.h.

#define SPDY_HTTP_HEADER_LOCATION   "location"

Definition at line 221 of file microspdy.h.

#define SPDY_HTTP_HEADER_MAX_FORWARDS   "max-forwards"

Definition at line 222 of file microspdy.h.

#define SPDY_HTTP_HEADER_PRAGMA   "pragma"

Definition at line 223 of file microspdy.h.

#define SPDY_HTTP_HEADER_PROXY_AUTHENTICATE   "proxy-authenticate"

Definition at line 224 of file microspdy.h.

#define SPDY_HTTP_HEADER_PROXY_AUTHORIZATION   "proxy-authorization"

Definition at line 225 of file microspdy.h.

#define SPDY_HTTP_HEADER_PROXY_CONNECTION   "proxy-connection"

Definition at line 227 of file microspdy.h.

#define SPDY_HTTP_HEADER_RANGE   "range"

Definition at line 228 of file microspdy.h.

#define SPDY_HTTP_HEADER_REFERER   "referer"

Definition at line 229 of file microspdy.h.

#define SPDY_HTTP_HEADER_RETRY_AFTER   "retry-after"

Definition at line 230 of file microspdy.h.

#define SPDY_HTTP_HEADER_SERVER   "server"

Definition at line 231 of file microspdy.h.

#define SPDY_HTTP_HEADER_SET_COOKIE   "set-cookie"

Definition at line 232 of file microspdy.h.

#define SPDY_HTTP_HEADER_SET_COOKIE2   "set-cookie2"

Definition at line 233 of file microspdy.h.

#define SPDY_HTTP_HEADER_TE   "te"

Definition at line 234 of file microspdy.h.

#define SPDY_HTTP_HEADER_TRAILER   "trailer"

Definition at line 235 of file microspdy.h.

#define SPDY_HTTP_HEADER_TRANSFER_ENCODING   "transfer-encoding"

Definition at line 237 of file microspdy.h.

Referenced by curl_header_cb().

#define SPDY_HTTP_HEADER_UPGRADE   "upgrade"

Definition at line 238 of file microspdy.h.

#define SPDY_HTTP_HEADER_USER_AGENT   "user-agent"

Definition at line 239 of file microspdy.h.

#define SPDY_HTTP_HEADER_VARY   "vary"

Definition at line 240 of file microspdy.h.

#define SPDY_HTTP_HEADER_VIA   "via"

Definition at line 241 of file microspdy.h.

#define SPDY_HTTP_HEADER_WARNING   "warning"

Definition at line 242 of file microspdy.h.

#define SPDY_HTTP_HEADER_WWW_AUTHENTICATE   "www-authenticate"

Definition at line 243 of file microspdy.h.

#define SPDY_HTTP_HTTP_VERSION_NOT_SUPPORTED   505

Definition at line 177 of file microspdy.h.

#define SPDY_HTTP_INSUFFICIENT_STORAGE   507

Definition at line 179 of file microspdy.h.

#define SPDY_HTTP_INTERNAL_SERVER_ERROR   500

Definition at line 172 of file microspdy.h.

#define SPDY_HTTP_LENGTH_REQUIRED   411

Definition at line 155 of file microspdy.h.

#define SPDY_HTTP_LOCKED   423

Definition at line 163 of file microspdy.h.

#define SPDY_HTTP_METHOD_CONNECT   "CONNECT"

HTTP methods

Definition at line 254 of file microspdy.h.

#define SPDY_HTTP_METHOD_DELETE   "DELETE"

Definition at line 255 of file microspdy.h.

#define SPDY_HTTP_METHOD_GET   "GET"

Definition at line 256 of file microspdy.h.

#define SPDY_HTTP_METHOD_HEAD   "HEAD"

Definition at line 257 of file microspdy.h.

#define SPDY_HTTP_METHOD_NOT_ACCEPTABLE   406

Definition at line 150 of file microspdy.h.

#define SPDY_HTTP_METHOD_NOT_ALLOWED   405

Definition at line 149 of file microspdy.h.

#define SPDY_HTTP_METHOD_OPTIONS   "OPTIONS"

Definition at line 258 of file microspdy.h.

#define SPDY_HTTP_METHOD_POST   "POST"

Definition at line 259 of file microspdy.h.

Referenced by standard_request_handler().

#define SPDY_HTTP_METHOD_PUT   "PUT"

Definition at line 260 of file microspdy.h.

#define SPDY_HTTP_METHOD_TRACE   "TRACE"

Definition at line 261 of file microspdy.h.

#define SPDY_HTTP_MOVED_PERMANENTLY   301

Definition at line 136 of file microspdy.h.

#define SPDY_HTTP_MULTI_STATUS   207

Definition at line 133 of file microspdy.h.

#define SPDY_HTTP_MULTIPLE_CHOICES   300

Definition at line 135 of file microspdy.h.

#define SPDY_HTTP_NO_CONTENT   204

Definition at line 130 of file microspdy.h.

#define SPDY_HTTP_NO_RESPONSE   444

Definition at line 167 of file microspdy.h.

#define SPDY_HTTP_NON_AUTHORITATIVE_INFORMATION   203

Definition at line 129 of file microspdy.h.

#define SPDY_HTTP_NOT_EXTENDED   510

Definition at line 181 of file microspdy.h.

#define SPDY_HTTP_NOT_FOUND   404

Definition at line 148 of file microspdy.h.

#define SPDY_HTTP_NOT_IMPLEMENTED   501

Definition at line 173 of file microspdy.h.

#define SPDY_HTTP_NOT_MODIFIED   304

Definition at line 139 of file microspdy.h.

#define SPDY_HTTP_OK   200

Definition at line 126 of file microspdy.h.

#define SPDY_HTTP_PARTIAL_CONTENT   206

Definition at line 132 of file microspdy.h.

#define SPDY_HTTP_PAYMENT_REQUIRED   402

Definition at line 146 of file microspdy.h.

#define SPDY_HTTP_POST_ENCODING_FORM_URLENCODED   "application/x-www-form-urlencoded"

HTTP POST encodings, see also http://www.w3.org/TR/html4/interact/forms.html#h-17.13.4

Definition at line 267 of file microspdy.h.

#define SPDY_HTTP_POST_ENCODING_MULTIPART_FORMDATA   "multipart/form-data"

Definition at line 268 of file microspdy.h.

#define SPDY_HTTP_PRECONDITION_FAILED   412

Definition at line 156 of file microspdy.h.

#define SPDY_HTTP_PROCESSING   102

Definition at line 124 of file microspdy.h.

#define SPDY_HTTP_PROXY_AUTHENTICATION_REQUIRED   407

Definition at line 151 of file microspdy.h.

#define SPDY_HTTP_REQUEST_ENTITY_TOO_LARGE   413

Definition at line 157 of file microspdy.h.

#define SPDY_HTTP_REQUEST_TIMEOUT   408

Definition at line 152 of file microspdy.h.

#define SPDY_HTTP_REQUEST_URI_TOO_LONG   414

Definition at line 158 of file microspdy.h.

#define SPDY_HTTP_REQUESTED_RANGE_NOT_SATISFIABLE   416

Definition at line 160 of file microspdy.h.

#define SPDY_HTTP_RESET_CONTENT   205

Definition at line 131 of file microspdy.h.

#define SPDY_HTTP_RETRY_WITH   449

Definition at line 168 of file microspdy.h.

#define SPDY_HTTP_SEE_OTHER   303

Definition at line 138 of file microspdy.h.

#define SPDY_HTTP_SERVICE_UNAVAILABLE   503

Definition at line 175 of file microspdy.h.

#define SPDY_HTTP_SWITCH_PROXY   306

Definition at line 141 of file microspdy.h.

#define SPDY_HTTP_SWITCHING_PROTOCOLS   101

Definition at line 123 of file microspdy.h.

#define SPDY_HTTP_TEMPORARY_REDIRECT   307

Definition at line 142 of file microspdy.h.

#define SPDY_HTTP_UNAUTHORIZED   401

Definition at line 145 of file microspdy.h.

#define SPDY_HTTP_UNAVAILABLE_FOR_LEGAL_REASONS   451

Definition at line 170 of file microspdy.h.

#define SPDY_HTTP_UNORDERED_COLLECTION   425

Definition at line 165 of file microspdy.h.

#define SPDY_HTTP_UNPROCESSABLE_ENTITY   422

Definition at line 162 of file microspdy.h.

#define SPDY_HTTP_UNSUPPORTED_MEDIA_TYPE   415

Definition at line 159 of file microspdy.h.

#define SPDY_HTTP_UPGRADE_REQUIRED   426

Definition at line 166 of file microspdy.h.

#define SPDY_HTTP_USE_PROXY   305

Definition at line 140 of file microspdy.h.

#define SPDY_HTTP_VARIANT_ALSO_NEGOTIATES   506

Definition at line 178 of file microspdy.h.

#define SPDY_HTTP_VERSION_1_0   "HTTP/1.0"

HTTP versions (a value must be provided in SPDY requests/responses).

Definition at line 248 of file microspdy.h.

#define SPDY_HTTP_VERSION_1_1   "HTTP/1.1"

Definition at line 249 of file microspdy.h.

Referenced by run().

#define SPDY_init ( )    SPDY_init (SPDY_IO_SUBSYSTEM_OPENSSL)

Definition at line 826 of file microspdy.h.

Referenced by run().

#define SPDY_INPUT_ERROR   -1

return code for error when input parameters are wrong. To be returned only by functions which return int. The others will return NULL on input error.

Definition at line 105 of file microspdy.h.

Referenced by SPDY_get_fdset(), SPDY_get_timeout(), SPDY_name_value_add(), SPDY_name_value_iterate(), SPDY_queue_response(), and SPDYF_name_value_from_stream().

#define SPDY_MAX_SUPPORTED_FRAME_SIZE   8192

The maximum allowed size (without 8 byte headers) of SPDY frames (value length) is 8192. The lib will accept and send frames with length at most this value here.

Definition at line 117 of file microspdy.h.

Referenced by SPDY_build_response_with_callback(), SPDY_init(), SPDYF_handler_ignore_frame(), spdyf_handler_read_data(), spdyf_handler_read_goaway(), spdyf_handler_read_syn_stream(), and SPDYF_response_queue_create().

#define SPDY_VERSION   3

SPDY version supported by the lib.

Definition at line 110 of file microspdy.h.

Referenced by SPDYF_prepare_goaway(), SPDYF_prepare_rst_stream(), SPDYF_prepare_window_update(), SPDYF_response_queue_create(), and SPDYF_session_idle().

Typedef Documentation

typedef int(* SPDY_NameValueIterator) (void *cls, const char *name, const char *const *value, int num_values)

Iterator over name-value pairs.

Parameters
clsclient-defined closure
nameof the pair
valueof the pair
Returns
SPDY_YES to continue iterating, SPDY_NO to abort the iteration

Definition at line 638 of file microspdy.h.

typedef int(* SPDY_NewDataCallback) (void *cls, struct SPDY_Request *request, const void *buf, size_t size, bool more)

Callback for received new data chunk (HTTP body) from a given request (e.g. POST data).

Parameters
clsclient-defined closure
requesthandler
bufdata chunk from the POST data
sizethe size of the data chunk 'buf' in bytes. Note that it may be 0.
morefalse if this is the last chunk from the data. Note: true does not mean that more data will come, exceptional situation is possible
Returns
SPDY_YES to continue calling the function, SPDY_NO to stop calling the function for this request

Definition at line 698 of file microspdy.h.

typedef void(* SPDY_NewRequestCallback) (void *cls, struct SPDY_Request *request, uint8_t priority, const char *method, const char *path, const char *version, const char *host, const char *scheme, struct SPDY_NameValue *headers, bool more)

Callback for received SPDY request. The functions is called whenever a reqest comes, but will also be called if more headers/trailers are received.

Parameters
clsclient-defined closure
requesthandler. The request object is required for sending responses.
priorityof the SPDY stream which the request was sent over
methodHTTP method
pathHTTP path
versionHTTP version just like in HTTP request/response: "HTTP/1.0" or "HTTP/1.1" currently
hostcalled host as in HTTP
schemeused ("http" or "https"). In SPDY 3 it is only "https".
headersother HTTP headers from the request
morea flag saying if more data related to the request is expected to be received. HTTP body may arrive (e.g. POST data); then SPDY_NewDataCallback will be called for the connection. It is also possible that more headers/trailers arrive; then the same callback will be invoked. The user should detect that it is not the first invocation of the function for that request.

Definition at line 670 of file microspdy.h.

typedef void(* SPDY_NewSessionCallback) (void *cls, struct SPDY_Session *session)

Callback for new SPDY session established by a client. Called immediately after the TCP connection was established.

Parameters
clsclient-defined closure
sessionhandler for the new SPDY session

Definition at line 606 of file microspdy.h.

typedef void(* SPDY_PanicCallback) (void *cls, const char *file, unsigned int line, const char *reason)

Callback for serious error condition. The default action is to print an error message and abort().

Parameters
clsuser specified value
filewhere the error occured
linewhere the error occured
reasonerror details message, may be NULL

Definition at line 592 of file microspdy.h.

typedef void(* SPDY_PingCallback) (void *cls, struct SPDY_Session *session, struct timeval *rtt)

Callback to notify when SPDY ping response is received.

Parameters
sessionhandler for which the ping request was sent
rttthe timespan between sending ping request and receiving it from the library

Definition at line 768 of file microspdy.h.

typedef ssize_t(* SPDY_ResponseCallback) (void *cls, void *buffer, size_t max, bool *more)

Callback to be used with SPDY_build_response_with_callback. The callback will be called when the lib wants to write to the TLS socket. The application should provide the data to be sent.

Parameters
clsclient-defined closure
maxmaximum number of bytes that are allowed to be written to the buffer.
moretrue if more data will be sent (i.e. the function must be calleed again), false if this is the last chunk, the lib will close the stream
Returns
number of bytes written to buffer. On error the call MUST return value less than 0 to indicate the library.

Definition at line 724 of file microspdy.h.

typedef void(* SPDY_ResponseResultCallback) (void *cls, struct SPDY_Response *response, struct SPDY_Request *request, enum SPDY_RESPONSE_RESULT status, bool streamopened)

Callback to be called when the last bytes from the response was sent to the client or when the response was discarded from the lib. This callback is a very good place to discard the request and the response objects, if they will not be reused (e.g., sending the same response again). If the stream is closed it is safe to discard the request object.

Parameters
clsclient-defined closure
responsehandler to the response that was just sent
requesthandler to the request for which the response was sent
statusshows if actually the response was sent or it was discarded by the lib for any reason (e.g., closing session, closing stream, stopping daemon, etc.). It is possible that status indicates an error but parts of the response headers and/or body (in one or several frames) were already sent to the client.
streamopenedindicates if the the stream for this request/ response pair is still opened. If yes, the server may want to use SPDY push to send something additional to the client and/or close the stream.

Definition at line 753 of file microspdy.h.

typedef void(* SPDY_SessionClosedCallback) (void *cls, struct SPDY_Session *session, int by_client)

Callback for closed session. Called after the TCP connection was closed. In this callback function the user has the last chance to access the SPDY_Session structure. After that the latter will be cleaned!

Parameters
clsclient-defined closure
sessionhandler for the closed SPDY session
by_clientSPDY_YES if the session close was initiated by the client; SPDY_NO if closed by the server

Definition at line 623 of file microspdy.h.

typedef int(* SPDY_SettingsIterator) (void *cls, enum SPDY_SETTINGS id, int32_t value, uint8_t flags)

Iterator over settings ID/Value/Flags tuples.

Parameters
clsclient-defined closure
idSPDY settings ID
valuevalue for this setting
flagsflags for this tuple; use enum SPDY_FLAG_SETTINGS
Returns
SPDY_YES to continue iterating, SPDY_NO to abort the iteration

Definition at line 785 of file microspdy.h.

typedef void(* SPDY_SettingsReceivedCallback) (struct SPDY_Session *session, struct SPDY_Settings *settings, uint8_t flags,...)

Callback to notify when SPDY SETTINGS are received from the client.

Parameters
sessionhandler for which settings are received
settingsID/value/flags tuples of the settings
flagsfor the whole settings frame; use enum SPDY_FLAG_SETTINGS_FRAME
...list of options (type-value pairs, terminated with SPDY_SETTINGS_OPTION_END).

Definition at line 802 of file microspdy.h.

Enumeration Type Documentation

Flags for starting SPDY daemon. They are used to set some settings for the daemon, which do not require values.

Enumerator
SPDY_DAEMON_FLAG_NO 

No flags selected.

SPDY_DAEMON_FLAG_ONLY_IPV6 

The server will bind only on IPv6 addresses. If the flag is set and the daemon is provided with IPv4 address or IPv6 is not supported, starting daemon will fail.

SPDY_DAEMON_FLAG_NO_DELAY 

All sessions' sockets will be set with TCP_NODELAY if the flag is used. Option considered only by SPDY_IO_SUBSYSTEM_RAW.

Definition at line 401 of file microspdy.h.

SPDY daemon options. Passed in the varargs portion of SPDY_start_daemon to customize the daemon. Each option must be followed by a value of a specific type.

The values are used internally as flags, that is why they must be powers of 2.

Enumerator
SPDY_DAEMON_OPTION_END 

No more options / last option. This is used to terminate the VARARGs list.

SPDY_DAEMON_OPTION_SESSION_TIMEOUT 

Set a custom timeout for all connections. Must be followed by a number of seconds, given as an 'unsigned int'. Use zero for no timeout.

SPDY_DAEMON_OPTION_SOCK_ADDR 

Bind daemon to the supplied sockaddr. This option must be followed by a 'struct sockaddr *'. The 'struct sockaddr*' should point to a 'struct sockaddr_in6' or to a 'struct sockaddr_in'.

SPDY_DAEMON_OPTION_FLAGS 

Flags for the daemon. Must be followed by a SPDY_DAEMON_FLAG value which is the result of bitwise OR of desired flags.

SPDY_DAEMON_OPTION_IO_SUBSYSTEM 

IO subsystem type used by daemon and all its sessions. If not set, TLS provided by openssl is used. Must be followed by a SPDY_IO_SUBSYSTEM value.

SPDY_DAEMON_OPTION_MAX_NUM_FRAMES 

Maximum number of frames to be written to the socket at once. The library tries to send max_num_frames in a single call to SPDY_run for a single session. This means no requests can be received nor other sessions can send data as long the current one has enough frames to send and there is no error on writing. Thus, a big value will affect the performance. Small value gives fairnes for sessions. Must be followed by a positive integer (uin32_t). If not set, the default value 10 will be used.

Definition at line 346 of file microspdy.h.

Flags for each individual SPDY setting in the SPDY SETTINGS frame. They affect only one setting to which they are set. Defined in SPDY Protocol - Draft 3.

Enumerator
SPDY_FLAG_SETTINGS_PERSIST_VALUE 

When set, the sender of this SETTINGS frame is requesting that the recipient persist the ID/Value and return it in future SETTINGS frames sent from the sender to this recipient. Because persistence is only implemented on the client, this flag is only sent by the server.

SPDY_FLAG_SETTINGS_PERSISTED 

When set, the sender is notifying the recipient that this ID/Value pair was previously sent to the sender by the recipient with the SPDY_FLAG_SETTINGS_PERSIST_VALUE, and the sender is returning it. Because persistence is only implemented on the client, this flag is only sent by the client.

Definition at line 493 of file microspdy.h.

Flag associated with a whole SPDY SETTINGS frame. Affect all the settings in the frame. Defined in SPDY Protocol - Draft 3.

Enumerator
SPDY_FLAG_SETTINGS_CLEAR_SETTINGS 

When set, the client should clear any previously persisted SETTINGS ID/Value pairs. If this frame contains ID/Value pairs with the SPDY_FLAG_SETTINGS_PERSIST_VALUE set, then the client will first clear its existing, persisted settings, and then persist the values with the flag set which are contained within this frame. Because persistence is only implemented on the client, this flag can only be used when the sender is the server.

Definition at line 520 of file microspdy.h.

SPDY IO sybsystem flags used by SPDY_init() and SPDY_deinit().

The values are used internally as flags, that is why they must be powers of 2.

Enumerator
SPDY_IO_SUBSYSTEM_NONE 

No subsystem. For internal use.

SPDY_IO_SUBSYSTEM_OPENSSL 

Default TLS implementation provided by openSSL/libssl.

SPDY_IO_SUBSYSTEM_RAW 

No TLS is used.

Definition at line 318 of file microspdy.h.

Used as a parameter for SPDY_ResponseResultCallback and shows if the response was actually written to the TLS socket or discarded by the lib for any reason (and respectively the reason).

Enumerator
SPDY_RESPONSE_RESULT_SUCCESS 

The lib has written the full response to the TLS socket.

SPDY_RESPONSE_RESULT_SESSION_CLOSED 

The session is being closed, so the data is being discarded

SPDY_RESPONSE_RESULT_STREAM_CLOSED 

The stream for this response has been closed. May happen when the sender had sent first SYN_STREAM and after that RST_STREAM.

Definition at line 561 of file microspdy.h.

SPDY settings IDs sent by both client and server in SPDY SETTINGS frame. They affect the whole SPDY session. Defined in SPDY Protocol - Draft 3.

Enumerator
SPDY_SETTINGS_UPLOAD_BANDWIDTH 

Allows the sender to send its expected upload bandwidth on this channel. This number is an estimate. The value should be the integral number of kilobytes per second that the sender predicts as an expected maximum upload channel capacity.

SPDY_SETTINGS_DOWNLOAD_BANDWIDTH 

Allows the sender to send its expected download bandwidth on this channel. This number is an estimate. The value should be the integral number of kilobytes per second that the sender predicts as an expected maximum download channel capacity.

SPDY_SETTINGS_ROUND_TRIP_TIME 

Allows the sender to send its expected round-trip-time on this channel. The round trip time is defined as the minimum amount of time to send a control frame from this client to the remote and receive a response. The value is represented in milliseconds.

SPDY_SETTINGS_MAX_CONCURRENT_STREAMS 

Allows the sender to inform the remote endpoint the maximum number of concurrent streams which it will allow. By default there is no limit. For implementors it is recommended that this value be no smaller than 100.

SPDY_SETTINGS_CURRENT_CWND 

Allows the sender to inform the remote endpoint of the current TCP CWND value.

SPDY_SETTINGS_DOWNLOAD_RETRANS_RATE 

Allows the sender to inform the remote endpoint the retransmission rate (bytes retransmitted / total bytes transmitted).

SPDY_SETTINGS_INITIAL_WINDOW_SIZE 

Allows the sender to inform the remote endpoint the initial window size (in bytes) for new streams.

SPDY_SETTINGS_CLIENT_CERTIFICATE_VECTOR_SIZE 

Allows the server to inform the client if the new size of the client certificate vector.

Definition at line 427 of file microspdy.h.

SPDY settings function options. Passed in the varargs portion of SPDY_SettingsReceivedCallback and SPDY_send_settings to customize more the settings handling. Each option must be followed by a value of a specific type.

The values are used internally as flags, that is why they must be powers of 2.

Enumerator
SPDY_SETTINGS_OPTION_END 

No more options / last option. This is used to terminate the VARARGs list.

Definition at line 545 of file microspdy.h.

Function Documentation

_MHD_EXTERN struct SPDY_Response* SPDY_build_response ( int  status,
const char *  statustext,
const char *  version,
struct SPDY_NameValue headers,
const void *  data,
size_t  size 
)

Create response object containing all needed headers and data. The response object is not bound to a request, so it can be used multiple times with SPDY_queue_response() and schould be destroied by calling the SPDY_destroy_response().

Currently the library does not provide compression of the body data. It is up to the user to pass already compressed data and the appropriate headers to this function when desired.

Parameters
statusHTTP status code for the response (e.g. 404)
statustextHTTP status message for the response, which will be appended to the status code (e.g. "OK"). Can be NULL
versionHTTP version for the response (e.g. "http/1.1")
headersname/value structure containing additional HTTP headers. Can be NULL. Can be used multiple times, it is up to the user to destoy the object when not needed anymore.
datathe body of the response. The lib will make a copy of it, so it is up to the user to take care of the memory pointed by data
sizelength of data. It can be 0, then the lib will send only headers
Returns
NULL on error, handle to response object on success

Definition at line 391 of file applicationlayer.c.

References SPDY_Response::data, SPDY_Response::data_size, SPDY_Response::headers, SPDY_Response::headers_size, NULL, SPDY_name_value_add(), SPDY_name_value_create(), SPDY_name_value_destroy(), SPDY_YES, SPDYF_DEBUG, SPDYF_name_value_is_empty(), and SPDYF_name_value_to_stream().

Referenced by run(), and SPDY_build_response_with_callback().

Here is the call graph for this function:

Here is the caller graph for this function:

_MHD_EXTERN struct SPDY_Response* SPDY_build_response_with_callback ( int  status,
const char *  statustext,
const char *  version,
struct SPDY_NameValue headers,
SPDY_ResponseCallback  rcb,
void *  rcb_cls,
uint32_t  block_size 
)

Create response object containing all needed headers. The data will be provided later when the lib calls the callback function (just before writing it to the TLS socket). The response object is not bound to a request, so it can be used multiple times with SPDY_queue_response() and schould be destroied by calling the SPDY_destroy_response().

Currently the library does not provide compression of the body data. It is up to the user to pass already compressed data and the appropriate headers to this function and the callback when desired.

Parameters
statusHTTP status code for the response (e.g. 404)
statustextHTTP status message for the response, which will be appended to the status code (e.g. "OK"). Can be NULL
versionHTTP version for the response (e.g. "http/1.1")
headersname/value structure containing additional HTTP headers. Can be NULL. Can be used multiple times, it is up to the user to destoy the object when not needed anymore.
rcbcallback to use to obtain response data
rcb_clsextra argument to rcb
block_sizepreferred block size for querying rcb (advisory only, the lib will call rcb specifying the block size); clients should pick a value that is appropriate for IO and memory performance requirements. The function will fail if the value is bigger than the maximum supported value (SPDY_MAX_SUPPORTED_FRAME_SIZE). Can be 0, then the lib will use SPDY_MAX_SUPPORTED_FRAME_SIZE instead.
Returns
NULL on error, handle to response object on success

Definition at line 480 of file applicationlayer.c.

References NULL, SPDY_Response::rcb, SPDY_Response::rcb_block_size, SPDY_Response::rcb_cls, SPDY_build_response(), SPDY_MAX_SUPPORTED_FRAME_SIZE, and SPDYF_DEBUG.

Referenced by curl_header_cb().

Here is the call graph for this function:

Here is the caller graph for this function:

_MHD_EXTERN void SPDY_close_session ( struct SPDY_Session session)

Closes a SPDY session. SPDY clients and servers are expected to keep sessions opened as long as possible. However, the server may want to close some connections, e.g. if there are too many, to free some resources. The function can also be used to close a specific session if the client is not desired.

Parameters
sessionhandler to be closed
_MHD_EXTERN void SPDY_deinit ( void  )

Deinit function for the whole lib. It can be called after finishing using the library. It frees and cleans up resources allocated in SPDY_init. Currently the function does not do anything.

Definition at line 260 of file applicationlayer.c.

References SPDY_IO_SUBSYSTEM_NONE, SPDY_IO_SUBSYSTEM_OPENSSL, SPDY_IO_SUBSYSTEM_RAW, SPDYF_ASSERT, spdyf_io_initialized, SPDYF_openssl_global_deinit(), and SPDYF_raw_global_deinit().

Referenced by run().

Here is the call graph for this function:

Here is the caller graph for this function:

_MHD_EXTERN void SPDY_destroy_request ( struct SPDY_Request request)

Destroy a request structure. It should be called for all objects received as a parameter in SPDY_NewRequestCallback to free the memory associated with the request. It is safe to call this function not before being sure that the request will not be used by the lib anymore, this means after the stream, on which this request had been sent, was closed and all SPDY_ResponseResultCallback callbacks were called for all calls to SPDY_queue_response() passing this request object.

Parameters
requestto destroy

Definition at line 30 of file alstructures.c.

References SPDY_Request::headers, NULL, SPDY_name_value_destroy(), and SPDYF_DEBUG.

Referenced by response_done_callback(), run(), spdy_callback_response_done(), and spdy_handler_new_stream().

Here is the call graph for this function:

Here is the caller graph for this function:

_MHD_EXTERN void SPDY_destroy_response ( struct SPDY_Response response)

Destroy a response structure. It should be called for all objects returned by SPDY_build_response*() functions to free the memory associated with the prepared response. It is safe to call this function not before being sure that the response will not be used by the lib anymore, this means after SPDY_ResponseResultCallback callbacks were called for all calls to SPDY_queue_response() passing this response.

Parameters
responseto destroy

Definition at line 279 of file structures.c.

References SPDY_Response::data, SPDY_Response::headers, and NULL.

Referenced by curl_header_cb(), response_done_callback(), run(), and spdy_callback_response_done().

Here is the caller graph for this function:

_MHD_EXTERN void* SPDY_get_cls_from_request ( struct SPDY_Request request)

Retrieves the pointer associated with the request by SPDY_set_cls_to_request().

Parameters
requestto get its cls
Returns
same pointer added by SPDY_set_cls_to_request() or NULL when nothing was associated

Definition at line 725 of file applicationlayer.c.

References NULL, SPDYF_DEBUG, and SPDY_Request::user_cls.

Referenced by spdy_post_data_cb(), and standard_request_handler().

Here is the caller graph for this function:

_MHD_EXTERN void* SPDY_get_cls_from_session ( struct SPDY_Session session)

Retrieves the pointer associated with SPDY_set_cls_to_session().

Parameters
sessionhandler to get its cls
Returns
same pointer added by SPDY_set_cls_to_session() or NULL when nothing was associated

Definition at line 698 of file applicationlayer.c.

References NULL, SPDYF_DEBUG, and SPDY_Session::user_cls.

Referenced by session_closed_cb(), and standard_request_handler().

Here is the caller graph for this function:

_MHD_EXTERN int SPDY_get_fdset ( struct SPDY_Daemon daemon,
fd_set *  read_fd_set,
fd_set *  write_fd_set,
fd_set *  except_fd_set 
)

Obtain the select sets for this daemon. Only those are retrieved, which some processing should be done for, i.e. not all sockets are added to write_fd_set.

It is possible that there is nothing to be read from a socket but there is data either in the TLS subsystem's read buffers or in libmicrospdy's read buffers, which waits for being processed. In such case the file descriptor will be added to write_fd_set. Since it is very likely for the socket to be ready for writing, the select used in the application's event loop will return with success, SPDY_run will be called, the data will be processed and maybe something will be written to the socket. Without this behaviour, considering a proper event loop, data may stay in the buffers, but run is never called.

Parameters
daemonto get sets from
read_fd_setread set
write_fd_setwrite set
except_fd_setexcept set
Returns
largest FD added to any of the sets

Definition at line 302 of file applicationlayer.c.

References NULL, SPDY_INPUT_ERROR, SPDYF_DEBUG, and SPDYF_get_fdset().

Referenced by run().

Here is the call graph for this function:

Here is the caller graph for this function:

_MHD_EXTERN socklen_t SPDY_get_remote_addr ( struct SPDY_Session session,
struct sockaddr **  addr 
)

Retrieves the remote address of a given session.

Parameters
sessionhandler to get its remote address
addrout parameter; pointing to remote address
Returns
length of the address structure

Definition at line 669 of file applicationlayer.c.

References SPDY_Session::addr, SPDY_Session::addr_len, NULL, and SPDYF_DEBUG.

_MHD_EXTERN struct SPDY_Session* SPDY_get_session_for_request ( const struct SPDY_Request request)

Gets the session responsible for the given request.

Parameters
requestfor which the session is wanted
Returns
session handler for the request

Definition at line 685 of file applicationlayer.c.

References NULL, SPDYF_Stream::session, SPDYF_DEBUG, and SPDY_Request::stream.

Referenced by standard_request_handler().

Here is the caller graph for this function:

_MHD_EXTERN int SPDY_get_timeout ( struct SPDY_Daemon daemon,
unsigned long long *  timeout 
)

Obtain timeout value for select for this daemon. The returned value is how long select should at most block, not the timeout value set for connections.

Parameters
daemonto query for timeout
timeoutwill be set to the timeout value (in milliseconds)
Returns
SPDY_YES on success SPDY_NO if no connections exist that would necessiate the use of a timeout right now

Definition at line 288 of file applicationlayer.c.

References NULL, SPDY_INPUT_ERROR, SPDYF_DEBUG, and SPDYF_get_timeout().

Referenced by run().

Here is the call graph for this function:

Here is the caller graph for this function:

_MHD_EXTERN int() SPDY_init ( enum SPDY_IO_SUBSYSTEM  io_subsystem,
  ... 
)

Init function for the whole library. It MUST be called before any other function of the library to initialize things like TLS context and possibly other stuff needed by the lib. Currently the call always returns SPDY_YES.

Parameters
io_subsystemthe IO subsystem that will be initialized. Several can be used with bitwise OR. If no parameter is set, the default openssl subsystem will be used.
Returns
SPDY_YES if the library was correctly initialized and its functions can be used now; SPDY_NO on error

Definition at line 232 of file applicationlayer.c.

References SPDY_IO_SUBSYSTEM_NONE, SPDY_IO_SUBSYSTEM_OPENSSL, SPDY_IO_SUBSYSTEM_RAW, SPDY_MAX_SUPPORTED_FRAME_SIZE, SPDY_YES, SPDYF_ASSERT, SPDYF_BUFFER_SIZE, spdyf_io_initialized, SPDYF_openssl_global_init(), and SPDYF_raw_global_init().

Here is the call graph for this function:

_MHD_EXTERN int SPDY_name_value_add ( struct SPDY_NameValue container,
const char *  name,
const char *  value 
)

Add name/value pair to a NameValue structure. SPDY_NO will be returned if the name/value pair is already in the structure. It is legal to add different values for the same name.

Parameters
containerstructure to which the new pair is added
namefor the value. Null-terminated string.
valuethe value itself. Null-terminated string.
Returns
SPDY_NO on error or SPDY_YES on success

Definition at line 56 of file structures.c.

References SPDY_NameValue::name, SPDY_NameValue::next, NULL, SPDY_NameValue::num_values, SPDY_NameValue::prev, SPDY_INPUT_ERROR, SPDY_NO, SPDY_YES, SPDYF_name_value_is_empty(), and SPDY_NameValue::value.

Referenced by curl_header_cb(), SPDY_build_response(), spdy_handler_new_stream(), and SPDYF_name_value_from_stream().

Here is the call graph for this function:

Here is the caller graph for this function:

_MHD_EXTERN struct SPDY_NameValue* SPDY_name_value_create ( void  )

Create a new NameValue structure. It is needed for putting inside the HTTP headers and their values for a response. The user should later destroy alone the structure.

Returns
handler to the new empty structure or NULL on error

Definition at line 42 of file structures.c.

References NULL.

Referenced by SPDY_build_response(), spdy_handler_new_stream(), SPDYF_name_value_from_stream(), and standard_request_handler().

Here is the caller graph for this function:

_MHD_EXTERN void SPDY_name_value_destroy ( struct SPDY_NameValue container)

Destroy a NameValue structure. Use this function to destroy only objects which, after passed to, will not be destroied by other functions.

Definition at line 218 of file structures.c.

References SPDY_NameValue::name, SPDY_NameValue::next, NULL, SPDY_NameValue::num_values, and SPDY_NameValue::value.

Referenced by curl_header_cb(), run(), SPDY_build_response(), SPDY_destroy_request(), spdy_handler_new_stream(), SPDYF_name_value_from_stream(), and SPDYF_stream_destroy().

Here is the caller graph for this function:

_MHD_EXTERN int SPDY_name_value_iterate ( struct SPDY_NameValue container,
SPDY_NameValueIterator  iterator,
void *  iterator_cls 
)

Iterate over name/value structure.

Parameters
containerstructure which to iterate over
iteratorcallback to call on each name/value pair; maybe NULL (then just count headers)
iterator_clsextra argument to iterator
Returns
number of entries iterated over

Definition at line 237 of file structures.c.

References SPDY_NameValue::name, SPDY_NameValue::next, NULL, SPDY_NameValue::num_values, SPDY_INPUT_ERROR, SPDY_YES, SPDYF_name_value_is_empty(), and SPDY_NameValue::value.

Referenced by standard_request_handler().

Here is the call graph for this function:

Here is the caller graph for this function:

_MHD_EXTERN const char* const* SPDY_name_value_lookup ( struct SPDY_NameValue container,
const char *  name,
int *  num_values 
)

Lookup value for a name in a name/value structure.

Parameters
containerstructure in which to lookup
namethe name to look for
num_valueslength of the returned array with values
Returns
NULL if no such item was found, or an array containing the values

Definition at line 190 of file structures.c.

References SPDY_NameValue::name, SPDY_NameValue::next, NULL, SPDY_NameValue::num_values, SPDYF_name_value_is_empty(), and SPDY_NameValue::value.

Referenced by curl_header_cb().

Here is the call graph for this function:

Here is the caller graph for this function:

_MHD_EXTERN int SPDY_queue_response ( struct SPDY_Request request,
struct SPDY_Response response,
bool  closestream,
bool  consider_priority,
SPDY_ResponseResultCallback  rrcb,
void *  rrcb_cls 
)

Queue response object to be sent to the client. A successfully queued response may never be sent, e.g. when the stream gets closed. The data will be added to the output queue. The call will fail, if the output for this session is closed (i.e. the session is closed, half or full) or the output channel for the stream, on which the request was received, is closed (i.e. the stream is closed, half or full).

Parameters
requestobject identifying the request to which the response is returned
responseobject containg headers and data to be sent
closestreamTRUE if the server does NOT intend to PUSH something more associated to this request/response later, FALSE otherwise
consider_priorityif FALSE, the response will be added to the end of the queue. If TRUE, the response will be added after the last previously added response with priority of the request grater or equal to that of the current one. This means that the function should be called with TRUE each time if one wants to be sure that the output queue behaves like a priority queue
rrcbcallback called when all the data was sent (last frame from response) or when that frame was discarded (e.g. the stream has been closed meanwhile)
rrcb_clsextra argument to rrcb
Returns
SPDY_NO on error or SPDY_YES on success

Definition at line 525 of file applicationlayer.c.

References SPDY_Response::data, SPDY_Response::data_size, SPDYF_Response_Queue::frqcb, SPDYF_Response_Queue::frqcb_cls, SPDY_Response::headers, SPDY_Response::headers_size, SPDYF_Stream::is_out_closed, NULL, SPDY_Response::rcb, SPDYF_Stream::session, spdy_handler_response_queue_result(), SPDY_INPUT_ERROR, SPDY_NO, SPDY_SESSION_STATUS_CLOSING, SPDY_YES, SPDYF_DEBUG, SPDYF_queue_response(), SPDYF_response_queue_create(), SPDYF_response_queue_destroy(), SPDY_Session::status, and SPDY_Request::stream.

Referenced by curl_header_cb(), and run().

Here is the call graph for this function:

Here is the caller graph for this function:

_MHD_EXTERN void SPDY_run ( struct SPDY_Daemon daemon)

Run webserver operations. This method must be called in the client event loop.

Parameters
daemonto run

Definition at line 275 of file applicationlayer.c.

References NULL, SPDYF_DEBUG, and SPDYF_run().

Referenced by run().

Here is the call graph for this function:

Here is the caller graph for this function:

_MHD_EXTERN int SPDY_send_ping ( struct SPDY_Session session,
SPDY_PingCallback  rttcb,
void *  rttcb_cls 
)

Send SPDY ping to the client

Parameters
sessionhandler for which the ping request is sent
rttcbcallback called when ping response to the request is received
rttcb_clsextra argument to rttcb
Returns
SPDY_NO on error or SPDY_YES on success
_MHD_EXTERN int SPDY_send_settings ( struct SPDY_Session session,
struct SPDY_Settings *  settings,
enum SPDY_FLAG_SETTINGS_FRAME  flags,
  ... 
)

Send SPDY SETTINGS to the client. The call will return fail if there in invald setting into the settings container (e.g. invalid setting ID).

Parameters
sessionSPDY_Session handler for which settings are being sent
settingsID/value pairs of the settings to be sent. Can be used multiple times, it is up to the user to destoy the object when not needed anymore.
flagsfor the whole settings frame. They are valid for all tuples
...list of options (type-value pairs, terminated with SPDY_SETTINGS_OPTION_END).
Returns
SPDY_NO on error or SPDY_YES on success
_MHD_EXTERN void SPDY_set_cls_to_request ( struct SPDY_Request request,
void *  cls 
)

Associate a void pointer with a request. The data accessible by the pointer can later be used wherever the request handler is available.

Parameters
requestwith which to associate a pointer
clsany data pointed by a pointer to be accessible later

Definition at line 738 of file applicationlayer.c.

References NULL, SPDYF_DEBUG, and SPDY_Request::user_cls.

Referenced by standard_request_handler().

Here is the caller graph for this function:

_MHD_EXTERN void SPDY_set_cls_to_session ( struct SPDY_Session session,
void *  cls 
)

Associate a void pointer with a session. The data accessible by the pointer can later be used wherever the session handler is available.

Parameters
sessionhandler
clsany data pointed by a pointer to be accessible later

Definition at line 711 of file applicationlayer.c.

References NULL, SPDYF_DEBUG, and SPDY_Session::user_cls.

Referenced by new_session_cb().

Here is the caller graph for this function:

_MHD_EXTERN void SPDY_set_panic_func ( SPDY_PanicCallback  cb,
void *  cls 
)

Sets the global error handler to a different implementation. "cb" will only be called in the case of typically fatal, serious internal consistency issues. These issues should only arise in the case of serious memory corruption or similar problems with the architecture as well as failed assertions. While "cb" is allowed to return and the lib will then try to continue, this is never safe.

The default implementation that is used if no panic function is set simply prints an error message and calls "abort". Alternative implementations might call "exit" or other similar functions.

Parameters
cbnew error handler
clspassed to error handler

Definition at line 161 of file daemon.c.

References spdyf_panic, and spdyf_panic_cls.

_MHD_EXTERN int SPDY_settings_add ( struct SPDY_Settings *  container,
enum SPDY_SETTINGS  id,
enum SPDY_FLAG_SETTINGS  flags,
int32_t  value 
)

Add or update a tuple to a SettingsIDValue structure.

Parameters
containerstructure to which the new tuple is added
idSPDY settings ID that will be sent. If this ID already in container, the tupple for it will be updated (value and/or flags). If it is not in the container, a new tupple will be added.
flagsSPDY settings flags applied only to this setting
valueof the setting
Returns
SPDY_NO on error or SPDY_YES if a new setting was added
_MHD_EXTERN const struct SPDY_Settings* SPDY_settings_create ( void  )

Create a new SettingsIDValue structure. It is needed for putting inside tuples of SPDY option, flags and value for sending to the client.

Returns
hendler to the new empty structure or NULL on error
_MHD_EXTERN void SPDY_settings_destroy ( struct SPDY_Settings *  container)

Destroy a settings ID/value structure. Use this function to destroy only objects which, after passed to, will not be destroied by other functions.

Parameters
containerstructure which to detroy
_MHD_EXTERN int SPDY_settings_iterate ( const struct SPDY_Settings *  container,
SPDY_SettingsIterator  iterator,
void *  iterator_cls 
)

Iterate over settings ID/value structure.

Parameters
containerstructure which to iterate over
iteratorcallback to call on each ID/value pair; maybe NULL (then just count number of settings)
iterator_clsextra argument to iterator
Returns
number of entries iterated over
_MHD_EXTERN int SPDY_settings_lookup ( const struct SPDY_Settings *  container,
enum SPDY_SETTINGS  id,
enum SPDY_FLAG_SETTINGS flags,
int32_t *  value 
)

Lookup value and flags for an ID in a settings ID/value structure.

Parameters
containerstructure in which to lookup
idSPDY settings ID to search for
flagsout param for SPDY settings flags for this setting; check it against the flags in enum SPDY_FLAG_SETTINGS
valueout param for the value of this setting
Returns
SPDY_NO if the setting is not into the structure or SPDY_YES if it is into it
_MHD_EXTERN struct SPDY_Daemon* SPDY_start_daemon ( uint16_t  port,
const char *  certfile,
const char *  keyfile,
SPDY_NewSessionCallback  nscb,
SPDY_SessionClosedCallback  sccb,
SPDY_NewRequestCallback  nrcb,
SPDY_NewDataCallback  npdcb,
void *  cls,
  ... 
)

Start a SPDY webserver on the given port.

Parameters
portto bind to. The value is ignored if address structure is passed as daemon option
certfilepath to the certificate that will be used by server
keyfilepath to the keyfile for the certificate
nscbcallback called when a new SPDY session is established by a client
sccbcallback called when a session is closed
nrcbcallback called when a client sends request
npdcbcallback called when HTTP body (POST data) is received after request
clscommon extra argument to all of the callbacks
...list of options (type-value pairs, terminated with SPDY_DAEMON_OPTION_END).
Returns
NULL on error, handle to daemon on success

Definition at line 325 of file applicationlayer.c.

References NULL, spdy_handler_new_data(), spdy_handler_new_stream(), SPDY_IO_SUBSYSTEM_NONE, SPDYF_DEBUG, spdyf_io_initialized, and SPDYF_start_daemon_va().

Referenced by run().

Here is the call graph for this function:

Here is the caller graph for this function:

_MHD_EXTERN void SPDY_stop_daemon ( struct SPDY_Daemon daemon)

Shutdown the daemon. First all sessions are closed. It is NOT safe to call this function in user callbacks.

Parameters
daemonto stop

Definition at line 378 of file applicationlayer.c.

References NULL, SPDYF_DEBUG, and SPDYF_stop_daemon().

Referenced by run().

Here is the call graph for this function:

Here is the caller graph for this function: