91 while(iterator !=
NULL)
93 if(strcmp(
":method",iterator->
name) == 0)
97 method = iterator->
value[0];
99 else if(strcmp(
":path",iterator->
name) == 0)
103 path = iterator->
value[0];
105 else if(strcmp(
":version",iterator->
name) == 0)
109 version = iterator->
value[0];
111 else if(strcmp(
":host",iterator->
name) == 0)
116 host = iterator->
value[0];
118 else if(strcmp(
":scheme",iterator->
name) == 0)
122 scheme = iterator->
value[0];
132 iterator = iterator->
next;
143 if(
NULL == method || strlen(method) == 0
144 ||
NULL == path || strlen(path) == 0
145 ||
NULL == version || strlen(version) == 0
146 ||
NULL == host || strlen(host) == 0
147 ||
NULL == scheme || strlen(scheme) == 0
171 stream->
cls = request;
223 "response queue must have either control frame or data frame");
227 response_queue->
rrcb(response_queue->
rrcb_cls, response_queue->
response, request, status, streamopened);
235 "Buffer size is less than max supported frame size!");
237 "Max supported frame size must be bigger than the minimal value!");
239 "SPDY_init must be called only once per program or after SPDY_deinit");
253 "SPDY_init could not find even one IO subsystem");
263 "SPDY_init has not been called!");
289 unsigned long long *timeout)
304 fd_set *write_fd_set,
305 fd_set *except_fd_set)
308 ||
NULL == read_fd_set
309 ||
NULL == write_fd_set
310 ||
NULL == except_fd_set)
357 va_start(valist, cls);
392 const char * statustext,
393 const char * version,
400 char *fullstatus =
NULL;
402 int num_hdr_containers = 1;
415 num_hdr_containers = 2;
417 if(
NULL == (all_headers = malloc(num_hdr_containers *
sizeof(
struct SPDY_NameValue *))))
419 memset(all_headers, 0, num_hdr_containers *
sizeof(
struct SPDY_NameValue *));
421 if(2 == num_hdr_containers)
422 all_headers[1] = headers;
427 if(
NULL == statustext)
428 ret = asprintf(&fullstatus,
"%i", status);
430 ret = asprintf(&fullstatus,
"%i %s", status, statustext);
455 if(
NULL == (response->
data = malloc(size)))
460 memcpy(response->
data, data, size);
470 if(
NULL != all_headers)
481 const char * statustext,
482 const char * version,
528 bool consider_priority,
594 int_consider_priority);
598 int_consider_priority);
620 int_consider_priority);
657 int_consider_priority);
661 int_consider_priority);
670 struct sockaddr ** addr)
678 *addr = session->
addr;
struct SPDYF_Response_Queue * SPDYF_response_queue_create(bool is_data, void *data, size_t data_size, struct SPDY_Response *response, struct SPDYF_Stream *stream, bool closestream, SPDYF_ResponseQueueResultCallback frqcb, void *frqcb_cls, SPDY_ResponseResultCallback rrcb, void *rrcb_cls)
struct SPDY_Daemon * SPDYF_start_daemon_va(uint16_t port, const char *certfile, const char *keyfile, SPDY_NewSessionCallback nscb, SPDY_SessionClosedCallback sccb, SPDY_NewRequestCallback nrcb, SPDY_NewDataCallback npdcb, SPDYF_NewStreamCallback fnscb, SPDYF_NewDataCallback fndcb, void *cls, void *fcls, va_list valist)
static int spdy_handler_new_data(void *cls, struct SPDYF_Stream *stream, const void *buf, size_t size, bool more)
int SPDYF_get_fdset(struct SPDY_Daemon *daemon, fd_set *read_fd_set, fd_set *write_fd_set, fd_set *except_fd_set, bool all)
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)
void SPDY_set_cls_to_session(struct SPDY_Session *session, void *cls)
socklen_t SPDY_get_remote_addr(struct SPDY_Session *session, struct sockaddr **addr)
int SPDYF_get_timeout(struct SPDY_Daemon *daemon, unsigned long long *timeout)
int SPDY_get_fdset(struct SPDY_Daemon *daemon, fd_set *read_fd_set, fd_set *write_fd_set, fd_set *except_fd_set)
struct SPDY_Daemon * daemon
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 int SPDY_name_value_add(struct SPDY_NameValue *container, const char *name, const char *value)
SPDY application or HTTP layer.
struct SPDYF_Stream * stream
struct SPDYF_Control_Frame * control_frame
TCP connection/SPDY session handling.
SPDY_NewRequestCallback new_request_cb
static int spdy_handler_new_stream(void *cls, struct SPDYF_Stream *stream)
void(* SPDY_NewSessionCallback)(void *cls, struct SPDY_Session *session)
void SPDYF_response_queue_destroy(struct SPDYF_Response_Queue *response_queue)
internal functions and macros for the framing layer
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)
void * SPDY_get_cls_from_session(struct SPDY_Session *session)
void SPDYF_queue_response(struct SPDYF_Response_Queue *response_to_queue, struct SPDY_Session *session, int consider_priority)
internal and public structures – most of the structs used by the library are defined here ...
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,...)
void SPDYF_openssl_global_init()
int SPDYF_name_value_is_empty(struct SPDY_NameValue *container)
void SPDYF_openssl_global_deinit()
SPDYF_ResponseQueueResultCallback frqcb
#define SPDY_MAX_SUPPORTED_FRAME_SIZE
_MHD_EXTERN struct SPDY_NameValue * SPDY_name_value_create(void)
SPDY_ResponseCallback rcb
_MHD_EXTERN void SPDY_destroy_response(struct SPDY_Response *response)
structures only for the application layer
void(* SPDY_SessionClosedCallback)(void *cls, struct SPDY_Session *session, int by_client)
struct SPDY_NameValue * next
void(* SPDY_ResponseResultCallback)(void *cls, struct SPDY_Response *response, struct SPDY_Request *request, enum SPDY_RESPONSE_RESULT status, bool streamopened)
struct SPDY_Response * SPDY_build_response(int status, const char *statustext, const char *version, struct SPDY_NameValue *headers, const void *data, size_t size)
enum SPDY_IO_SUBSYSTEM spdyf_io_initialized
_MHD_EXTERN void SPDY_destroy_request(struct SPDY_Request *request)
#define SPDYF_BUFFER_SIZE
int(* SPDY_NewDataCallback)(void *cls, struct SPDY_Request *request, const void *buf, size_t size, bool more)
void SPDYF_stop_daemon(struct SPDY_Daemon *daemon)
#define SPDYF_DEBUG(fmt,...)
void(* SPDYF_ResponseQueueResultCallback)(void *cls, struct SPDYF_Response_Queue *response_queue, enum SPDY_RESPONSE_RESULT status)
void spdy_callback_response_done(void *cls, struct SPDY_Response *response, struct SPDY_Request *request, enum SPDY_RESPONSE_RESULT status, bool streamopened)
void SPDY_run(struct SPDY_Daemon *daemon)
struct SPDYF_Data_Frame * data_frame
ssize_t SPDYF_name_value_to_stream(struct SPDY_NameValue *container[], int num_containers, void **stream)
enum SPDY_SESSION_STATUS status
#define SPDYF_ASSERT(expr, msg)
void SPDYF_raw_global_init()
void SPDYF_run(struct SPDY_Daemon *daemon)
_MHD_EXTERN void SPDY_name_value_destroy(struct SPDY_NameValue *container)
void * SPDY_get_cls_from_request(struct SPDY_Request *request)
static void spdy_handler_response_queue_result(void *cls, struct SPDYF_Response_Queue *response_queue, enum SPDY_RESPONSE_RESULT status)
struct SPDY_NameValue * headers
struct SPDY_Session * SPDY_get_session_for_request(const struct SPDY_Request *request)
void SPDYF_raw_global_deinit()
SPDY_ResponseResultCallback rrcb
void SPDY_stop_daemon(struct SPDY_Daemon *daemon)
ssize_t(* SPDY_ResponseCallback)(void *cls, void *buffer, size_t max, bool *more)
void SPDY_set_cls_to_request(struct SPDY_Request *request, void *cls)
struct SPDY_NameValue * headers
int() SPDY_init(enum SPDY_IO_SUBSYSTEM io_subsystem,...)
int SPDY_get_timeout(struct SPDY_Daemon *daemon, unsigned long long *timeout)
struct SPDYF_Stream * stream
struct SPDY_Response * response
SPDY_NewDataCallback received_data_cb
struct SPDY_Session * session