GNU libmicrohttpd
0.9.29
|
Translates incoming SPDY requests to http server on localhost. Uses libcurl. No error handling for curl requests. TODO: More...
#include "platform.h"
#include <unistd.h>
#include <stdlib.h>
#include <stdint.h>
#include <stdbool.h>
#include <string.h>
#include <stdio.h>
#include <ctype.h>
#include <errno.h>
#include "microspdy.h"
#include <curl/curl.h>
#include <assert.h>
#include <getopt.h>
#include <regex.h>
Go to the source code of this file.
Macros | |
#define | ERROR_RESPONSE "502 Bad Gateway" |
#define | PRINT_INFO(msg) |
#define | PRINT_INFO2(fmt,...) |
#define | PRINT_VERBOSE(msg) |
#define | PRINT_VERBOSE2(fmt,...) |
#define | CURL_SETOPT(handle, opt, val) |
#define | DIE(msg) |
Functions | |
static void | free_uri (struct URI *uri) |
static int | init_parse_uri (regex_t *preg) |
static void | deinit_parse_uri (regex_t *preg) |
static int | parse_uri (regex_t *preg, const char *full_uri, struct URI **uri) |
static bool | store_in_buffer (const void *src, size_t src_size, void **dst, size_t *dst_size) |
static ssize_t | get_from_buffer (void **src, size_t *src_size, void *dst, size_t max_size) |
static void | catch_signal (int signal) |
static void | new_session_cb (void *cls, struct SPDY_Session *session) |
static void | session_closed_cb (void *cls, struct SPDY_Session *session, int by_client) |
static int | spdy_post_data_cb (void *cls, struct SPDY_Request *request, const void *buf, size_t size, bool more) |
ssize_t | response_callback (void *cls, void *buffer, size_t max, bool *more) |
static void | cleanup (struct Proxy *proxy) |
static void | response_done_callback (void *cls, struct SPDY_Response *response, struct SPDY_Request *request, enum SPDY_RESPONSE_RESULT status, bool streamopened) |
static size_t | curl_header_cb (void *ptr, size_t size, size_t nmemb, void *userp) |
static size_t | curl_write_cb (void *contents, size_t size, size_t nmemb, void *userp) |
static size_t | curl_read_cb (void *ptr, size_t size, size_t nmemb, void *userp) |
static int | iterate_cb (void *cls, const char *name, const char *const *value, int num_values) |
static void | standard_request_handler (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) |
static int | run () |
Variables | |
struct global_options | glob_opt |
static int | loop = 1 |
static CURLM * | multi_handle |
static int | still_running = 0 |
static regex_t | uri_preg |
static bool | call_spdy_run |
static bool | call_curl_run |
int | debug_num_curls |
Translates incoming SPDY requests to http server on localhost. Uses libcurl. No error handling for curl requests. TODO:
Definition in file proxy.c.
#define CURL_SETOPT | ( | handle, | |
opt, | |||
val | |||
) |
Definition at line 126 of file proxy.c.
Referenced by standard_request_handler().
#define DIE | ( | msg | ) |
Definition at line 137 of file proxy.c.
Referenced by cleanup(), curl_header_cb(), iterate_cb(), new_session_cb(), run(), and standard_request_handler().
#define ERROR_RESPONSE "502 Bad Gateway" |
#define PRINT_INFO | ( | msg | ) |
Definition at line 90 of file proxy.c.
Referenced by curl_read_cb(), curl_write_cb(), response_callback(), run(), spdy_post_data_cb(), and standard_request_handler().
#define PRINT_INFO2 | ( | fmt, | |
... | |||
) |
Definition at line 97 of file proxy.c.
Referenced by cleanup(), curl_header_cb(), run(), spdy_post_data_cb(), and standard_request_handler().
#define PRINT_VERBOSE | ( | msg | ) |
Definition at line 106 of file proxy.c.
Referenced by curl_header_cb(), curl_read_cb(), curl_write_cb(), new_session_cb(), response_callback(), run(), and spdy_post_data_cb().
#define PRINT_VERBOSE2 | ( | fmt, | |
... | |||
) |
Definition at line 115 of file proxy.c.
Referenced by curl_header_cb(), curl_read_cb(), curl_write_cb(), iterate_cb(), response_callback(), run(), session_closed_cb(), spdy_post_data_cb(), and standard_request_handler().
|
static |
|
static |
Definition at line 483 of file proxy.c.
References debug_num_curls, DIE, multi_handle, and PRINT_INFO2.
Referenced by internal_add_connection(), response_done_callback(), and run().
|
static |
Definition at line 528 of file proxy.c.
References call_spdy_run, DIE, NULL, PRINT_INFO2, PRINT_VERBOSE, PRINT_VERBOSE2, response_callback(), response_done_callback(), SPDY_build_response_with_callback(), SPDY_destroy_response(), SPDY_HTTP_HEADER_CONNECTION, SPDY_HTTP_HEADER_KEEP_ALIVE, SPDY_HTTP_HEADER_TRANSFER_ENCODING, SPDY_name_value_add(), SPDY_name_value_destroy(), SPDY_name_value_lookup(), SPDY_queue_response(), and SPDY_YES.
Referenced by standard_request_handler().
|
static |
Definition at line 727 of file proxy.c.
References get_from_buffer(), PRINT_INFO, PRINT_VERBOSE, and PRINT_VERBOSE2.
Referenced by standard_request_handler().
|
static |
Definition at line 683 of file proxy.c.
References call_spdy_run, PRINT_INFO, PRINT_VERBOSE, PRINT_VERBOSE2, and store_in_buffer().
Referenced by standard_request_handler().
|
static |
|
static |
Definition at line 189 of file proxy.c.
References NULL.
Referenced by parse_uri(), and standard_request_handler().
|
static |
Definition at line 332 of file proxy.c.
References NULL.
Referenced by curl_read_cb(), and response_callback().
|
static |
|
static |
Definition at line 790 of file proxy.c.
References DIE, NULL, PRINT_VERBOSE2, and SPDY_YES.
Referenced by standard_request_handler().
|
static |
Definition at line 367 of file proxy.c.
References DIE, NULL, PRINT_VERBOSE, and SPDY_set_cls_to_session().
Referenced by run().
|
static |
Definition at line 233 of file proxy.c.
References free_uri(), and NULL.
Referenced by standard_request_handler().
ssize_t response_callback | ( | void * | cls, |
void * | buffer, | ||
size_t | max, | ||
bool * | more | ||
) |
Definition at line 441 of file proxy.c.
References get_from_buffer(), PRINT_INFO, PRINT_VERBOSE, and PRINT_VERBOSE2.
Referenced by curl_header_cb().
|
static |
Definition at line 506 of file proxy.c.
References cleanup(), NULL, SPDY_destroy_request(), SPDY_destroy_response(), and SPDY_RESPONSE_RESULT_SUCCESS.
Referenced by curl_header_cb(), and run().
|
static |
Definition at line 972 of file proxy.c.
References call_curl_run, call_spdy_run, catch_signal(), cleanup(), debug_num_curls, deinit_parse_uri(), DIE, ERROR_RESPONSE, glob_opt, init_parse_uri(), loop, multi_handle, new_session_cb(), NULL, PRINT_INFO, PRINT_INFO2, PRINT_VERBOSE, PRINT_VERBOSE2, response_done_callback(), session_closed_cb(), SPDY_build_response(), SPDY_DAEMON_FLAG_NO, SPDY_DAEMON_FLAG_NO_DELAY, SPDY_DAEMON_OPTION_END, SPDY_DAEMON_OPTION_FLAGS, SPDY_DAEMON_OPTION_IO_SUBSYSTEM, SPDY_DAEMON_OPTION_SESSION_TIMEOUT, SPDY_DAEMON_OPTION_SOCK_ADDR, SPDY_deinit(), SPDY_destroy_request(), SPDY_destroy_response(), SPDY_get_fdset(), SPDY_get_timeout(), SPDY_HTTP_BAD_GATEWAY, SPDY_HTTP_VERSION_1_1, SPDY_init, SPDY_IO_SUBSYSTEM_OPENSSL, SPDY_IO_SUBSYSTEM_RAW, SPDY_name_value_destroy(), SPDY_NO, spdy_post_data_cb(), SPDY_queue_response(), SPDY_run(), SPDY_start_daemon(), SPDY_stop_daemon(), SPDY_YES, standard_request_handler(), still_running, and uri_preg.
|
static |
Definition at line 386 of file proxy.c.
References NULL, PRINT_VERBOSE2, and SPDY_get_cls_from_session().
Referenced by run().
|
static |
Definition at line 404 of file proxy.c.
References call_curl_run, PRINT_INFO, PRINT_INFO2, PRINT_VERBOSE, PRINT_VERBOSE2, SPDY_get_cls_from_request(), SPDY_YES, and store_in_buffer().
Referenced by run().
|
static |
Definition at line 830 of file proxy.c.
References call_curl_run, curl_header_cb(), curl_read_cb(), CURL_SETOPT, curl_write_cb(), debug_num_curls, DIE, free_uri(), glob_opt, iterate_cb(), multi_handle, NULL, parse_uri(), PRINT_INFO, PRINT_INFO2, PRINT_VERBOSE2, SPDY_get_cls_from_request(), SPDY_get_cls_from_session(), SPDY_get_session_for_request(), SPDY_HTTP_METHOD_POST, SPDY_name_value_create(), SPDY_name_value_iterate(), SPDY_set_cls_to_request(), still_running, and uri_preg.
Referenced by run().
|
static |
Definition at line 312 of file proxy.c.
References NULL.
Referenced by curl_write_cb(), and spdy_post_data_cb().
|
static |
Definition at line 154 of file proxy.c.
Referenced by run(), spdy_post_data_cb(), and standard_request_handler().
|
static |
Definition at line 153 of file proxy.c.
Referenced by curl_header_cb(), curl_write_cb(), and run().
int debug_num_curls |
Definition at line 156 of file proxy.c.
Referenced by cleanup(), run(), and standard_request_handler().
struct global_options glob_opt |
Referenced by run(), and standard_request_handler().
|
static |
Definition at line 145 of file proxy.c.
Referenced by catch_signal(), and run().
|
static |
Definition at line 147 of file proxy.c.
Referenced by cleanup(), run(), and standard_request_handler().
|
static |
Definition at line 149 of file proxy.c.
Referenced by run(), and standard_request_handler().
|
static |
Definition at line 151 of file proxy.c.
Referenced by run(), and standard_request_handler().