summaryrefslogtreecommitdiffstats
path: root/debian/vendor-h2o/include/h2o
diff options
context:
space:
mode:
Diffstat (limited to 'debian/vendor-h2o/include/h2o')
-rw-r--r--debian/vendor-h2o/include/h2o/cache.h114
-rw-r--r--debian/vendor-h2o/include/h2o/cache_digests.h66
-rw-r--r--debian/vendor-h2o/include/h2o/configurator.h181
-rw-r--r--debian/vendor-h2o/include/h2o/file.h29
-rw-r--r--debian/vendor-h2o/include/h2o/filecache.h68
-rw-r--r--debian/vendor-h2o/include/h2o/hostinfo.h91
-rw-r--r--debian/vendor-h2o/include/h2o/http1.h40
-rw-r--r--debian/vendor-h2o/include/h2o/http1client.h82
-rw-r--r--debian/vendor-h2o/include/h2o/http2.h67
-rw-r--r--debian/vendor-h2o/include/h2o/http2_casper.h56
-rw-r--r--debian/vendor-h2o/include/h2o/http2_internal.h512
-rw-r--r--debian/vendor-h2o/include/h2o/http2_scheduler.h134
-rw-r--r--debian/vendor-h2o/include/h2o/linklist.h119
-rw-r--r--debian/vendor-h2o/include/h2o/memcached.h50
-rw-r--r--debian/vendor-h2o/include/h2o/memory.h437
-rw-r--r--debian/vendor-h2o/include/h2o/mruby_.h178
-rw-r--r--debian/vendor-h2o/include/h2o/multithread.h107
-rw-r--r--debian/vendor-h2o/include/h2o/openssl_backport.h66
-rw-r--r--debian/vendor-h2o/include/h2o/rand.h35
-rw-r--r--debian/vendor-h2o/include/h2o/serverutil.h81
-rw-r--r--debian/vendor-h2o/include/h2o/socket.h403
-rw-r--r--debian/vendor-h2o/include/h2o/socket/evloop.h74
-rw-r--r--debian/vendor-h2o/include/h2o/socket/uv-binding.h44
-rw-r--r--debian/vendor-h2o/include/h2o/socketpool.h120
-rw-r--r--debian/vendor-h2o/include/h2o/string_.h194
-rw-r--r--debian/vendor-h2o/include/h2o/time_.h67
-rw-r--r--debian/vendor-h2o/include/h2o/timeout.h99
-rw-r--r--debian/vendor-h2o/include/h2o/token.h90
-rw-r--r--debian/vendor-h2o/include/h2o/tunnel.h38
-rw-r--r--debian/vendor-h2o/include/h2o/url.h147
-rw-r--r--debian/vendor-h2o/include/h2o/version.h35
-rw-r--r--debian/vendor-h2o/include/h2o/websocket.h58
32 files changed, 3882 insertions, 0 deletions
diff --git a/debian/vendor-h2o/include/h2o/cache.h b/debian/vendor-h2o/include/h2o/cache.h
new file mode 100644
index 0000000..4eae70c
--- /dev/null
+++ b/debian/vendor-h2o/include/h2o/cache.h
@@ -0,0 +1,114 @@
+/*
+ * Copyright (c) 2014-2016 DeNA Co., Ltd., Kazuho Oku
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+#ifndef h2o__cache_h
+#define h2o__cache_h
+
+#include <stdint.h>
+#include "h2o/linklist.h"
+#include "h2o/memory.h"
+
+typedef struct st_h2o_cache_t h2o_cache_t;
+
+typedef uint32_t /* eq. khint_t */ h2o_cache_hashcode_t;
+
+typedef struct st_h2o_cache_key_t {
+ h2o_iovec_t vec;
+ h2o_cache_hashcode_t hash;
+} h2o_cache_key_t;
+
+typedef struct st_h2o_cache_ref_t {
+ h2o_iovec_t key;
+ h2o_cache_hashcode_t keyhash;
+ uint64_t at;
+ h2o_iovec_t value;
+ int _requested_early_update;
+ h2o_linklist_t _lru_link;
+ h2o_linklist_t _age_link;
+ size_t _refcnt;
+} h2o_cache_ref_t;
+
+/**
+ * calculates the hash code of a key
+ */
+h2o_cache_hashcode_t h2o_cache_calchash(const char *s, size_t len);
+
+enum {
+ /**
+ * if set, the internals of the cache is protected by a mutex so that it can be accessed concurrently
+ */
+ H2O_CACHE_FLAG_MULTITHREADED = 0x1,
+ /**
+ * if set, the cache triggers an early update
+ */
+ H2O_CACHE_FLAG_EARLY_UPDATE = 0x2
+};
+
+/**
+ * creates a new cache
+ */
+h2o_cache_t *h2o_cache_create(int flags, size_t capacity, uint64_t duration, void (*destroy_cb)(h2o_iovec_t value));
+/**
+ * destroys a cache
+ */
+void h2o_cache_destroy(h2o_cache_t *cache);
+/**
+ * clears a cache
+ */
+void h2o_cache_clear(h2o_cache_t *cache);
+/**
+ * returns a value named by key from the cache if found, or else returns NULL
+ * @param cache
+ * @param now
+ * @param key
+ * @param keyhash callers may optionally pass in the precalculated hash value (or should be set to 0)
+ */
+h2o_cache_ref_t *h2o_cache_fetch(h2o_cache_t *cache, uint64_t now, h2o_iovec_t key, h2o_cache_hashcode_t keyhash);
+/**
+ * releases the reference returned by h2o_cache_fetch
+ */
+void h2o_cache_release(h2o_cache_t *cache, h2o_cache_ref_t *ref);
+/**
+ * sets the value of the cache
+ * @param cache
+ * @param now
+ * @param key
+ * @param keyhash callers may optionally pass in the precalculated hash value (or should be set to 0)
+ * @param value (when no longer needed, destroy_cb will be called)
+ * @return if the specified value already existed
+ */
+int h2o_cache_set(h2o_cache_t *cache, uint64_t now, h2o_iovec_t key, h2o_cache_hashcode_t keyhash, h2o_iovec_t value);
+/**
+ * deletes a named value from the cache
+ * @param cache
+ * @param now
+ * @param key
+ * @param keyhash callers may optionally pass in the precalculated hash value (or should be set to 0)
+ */
+void h2o_cache_delete(h2o_cache_t *cache, uint64_t now, h2o_iovec_t key, h2o_cache_hashcode_t keyhash);
+
+/**
+ * getter functions
+ */
+size_t h2o_cache_get_capacity(h2o_cache_t *cache);
+uint64_t h2o_cache_get_duration(h2o_cache_t *cache);
+
+#endif
diff --git a/debian/vendor-h2o/include/h2o/cache_digests.h b/debian/vendor-h2o/include/h2o/cache_digests.h
new file mode 100644
index 0000000..8680b38
--- /dev/null
+++ b/debian/vendor-h2o/include/h2o/cache_digests.h
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 2015 DeNA Co., Ltd., Kazuho Oku
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+#ifndef h2o__cache_digests_h
+#define h2o__cache_digests_h
+
+#include <stddef.h>
+#include <stdlib.h>
+#include "h2o/memory.h"
+
+typedef enum en_h2o_cache_digests_state_t {
+ H2O_CACHE_DIGESTS_STATE_UNKNOWN,
+ H2O_CACHE_DIGESTS_STATE_NOT_CACHED,
+ H2O_CACHE_DIGESTS_STATE_FRESH,
+ H2O_CACHE_DIGESTS_STATE_STALE
+} h2o_cache_digests_state_t;
+
+typedef struct st_h2o_cache_digests_frame_t h2o_cache_digests_frame_t;
+
+typedef H2O_VECTOR(h2o_cache_digests_frame_t) h2o_cache_digests_frame_vector_t;
+
+typedef struct st_h2o_cache_digests_t {
+ struct {
+ h2o_cache_digests_frame_vector_t url_only;
+ h2o_cache_digests_frame_vector_t url_and_etag;
+ int complete;
+ } fresh;
+} h2o_cache_digests_t;
+
+/**
+ * destroys the object
+ */
+void h2o_cache_digests_destroy(h2o_cache_digests_t *digests);
+/**
+ * loads a header (*digests may be NULL)
+ */
+void h2o_cache_digests_load_header(h2o_cache_digests_t **digests, const char *value, size_t len);
+/**
+ * lookup for a match with URL only
+ */
+h2o_cache_digests_state_t h2o_cache_digests_lookup_by_url(h2o_cache_digests_t *digests, const char *url, size_t url_len);
+/**
+ * lookup for a match with URL and etag
+ */
+h2o_cache_digests_state_t h2o_cache_digests_lookup_by_url_and_etag(h2o_cache_digests_t *digests, const char *url, size_t url_len,
+ const char *etag, size_t etag_len);
+
+#endif
diff --git a/debian/vendor-h2o/include/h2o/configurator.h b/debian/vendor-h2o/include/h2o/configurator.h
new file mode 100644
index 0000000..d1a2e25
--- /dev/null
+++ b/debian/vendor-h2o/include/h2o/configurator.h
@@ -0,0 +1,181 @@
+/*
+ * Copyright (c) 2014 DeNA Co., Ltd.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+#ifndef h2o__configurator_h
+#define h2o__configurator_h
+
+#include "yoml.h"
+
+enum {
+ H2O_CONFIGURATOR_FLAG_GLOBAL = 0x1,
+ H2O_CONFIGURATOR_FLAG_HOST = 0x2,
+ H2O_CONFIGURATOR_FLAG_PATH = 0x4,
+ H2O_CONFIGURATOR_FLAG_EXTENSION = 0x8,
+ H2O_CONFIGURATOR_FLAG_ALL_LEVELS =
+ H2O_CONFIGURATOR_FLAG_GLOBAL | H2O_CONFIGURATOR_FLAG_HOST | H2O_CONFIGURATOR_FLAG_PATH | H2O_CONFIGURATOR_FLAG_EXTENSION,
+ H2O_CONFIGURATOR_FLAG_EXPECT_SCALAR = 0x100,
+ H2O_CONFIGURATOR_FLAG_EXPECT_SEQUENCE = 0x200,
+ H2O_CONFIGURATOR_FLAG_EXPECT_MAPPING = 0x400,
+ H2O_CONFIGURATOR_FLAG_DEFERRED = 0x1000,
+ H2O_CONFIGURATOR_FLAG_SEMI_DEFERRED = 0x2000 /* used by file.custom-handler (invoked before hosts,paths,file-dir, etc.) */
+};
+
+#define H2O_CONFIGURATOR_NUM_LEVELS 4
+
+typedef struct st_h2o_configurator_context_t {
+ /**
+ * pointer to globalconf
+ */
+ h2o_globalconf_t *globalconf;
+ /**
+ * pointer to hostconf, or NULL if the context is above host level
+ */
+ h2o_hostconf_t *hostconf;
+ /**
+ * pointer to pathconf (either at path level or custom handler level), or NULL
+ */
+ h2o_pathconf_t *pathconf;
+ /**
+ * pointer to mimemap
+ */
+ h2o_mimemap_t **mimemap;
+ /**
+ * pointer to env
+ */
+ h2o_envconf_t *env;
+ /**
+ * if is a dry run
+ */
+ int dry_run;
+ /**
+ * parent context (or NULL if the context is at global level)
+ */
+ struct st_h2o_configurator_context_t *parent;
+} h2o_configurator_context_t;
+
+typedef int (*h2o_configurator_dispose_cb)(h2o_configurator_t *configurator);
+typedef int (*h2o_configurator_enter_cb)(h2o_configurator_t *configurator, h2o_configurator_context_t *ctx, yoml_t *node);
+typedef int (*h2o_configurator_exit_cb)(h2o_configurator_t *configurator, h2o_configurator_context_t *ctx, yoml_t *node);
+typedef int (*h2o_configurator_command_cb)(h2o_configurator_command_t *cmd, h2o_configurator_context_t *ctx, yoml_t *node);
+typedef h2o_headers_command_t **(*h2o_configurator_get_headers_commands_cb)(h2o_configurator_t *conf);
+
+struct st_h2o_configurator_command_t {
+ /**
+ * configurator to which the command belongs
+ */
+ h2o_configurator_t *configurator;
+ /**
+ * name of the command handled by the configurator
+ */
+ const char *name;
+ /**
+ * flags
+ */
+ int flags;
+ /**
+ * mandatory callback called to handle the command
+ */
+ h2o_configurator_command_cb cb;
+};
+
+/**
+ * basic structure of a configurator (handles a configuration command)
+ */
+struct st_h2o_configurator_t {
+ h2o_linklist_t _link;
+ /**
+ * optional callback called when the global config is being disposed
+ */
+ h2o_configurator_dispose_cb dispose;
+ /**
+ * optional callback called before the configuration commands are handled
+ */
+ h2o_configurator_enter_cb enter;
+ /**
+ * optional callback called after all the configuration commands are handled
+ */
+ h2o_configurator_exit_cb exit;
+ /**
+ * list of commands
+ */
+ H2O_VECTOR(h2o_configurator_command_t) commands;
+};
+
+/**
+ * registers a configurator
+ */
+h2o_configurator_t *h2o_configurator_create(h2o_globalconf_t *conf, size_t sz);
+/**
+ *
+ */
+void h2o_configurator_define_command(h2o_configurator_t *configurator, const char *name, int flags, h2o_configurator_command_cb cb);
+/**
+ * returns a configurator of given command name
+ * @return configurator for given name or NULL if not found
+ */
+h2o_configurator_command_t *h2o_configurator_get_command(h2o_globalconf_t *conf, const char *name);
+/**
+ * applies the configuration to the context
+ * @return 0 if successful, -1 if not
+ */
+int h2o_configurator_apply(h2o_globalconf_t *config, yoml_t *node, int dry_run);
+/**
+ *
+ */
+int h2o_configurator_apply_commands(h2o_configurator_context_t *ctx, yoml_t *node, int flags_mask, const char **ignore_commands);
+/**
+ * emits configuration error
+ */
+void h2o_configurator_errprintf(h2o_configurator_command_t *cmd, yoml_t *node, const char *reason, ...)
+ __attribute__((format(printf, 3, 4)));
+/**
+ * interprets the configuration value using sscanf, or prints an error upon failure
+ * @param configurator configurator
+ * @param node configuration value
+ * @param fmt scanf-style format string
+ * @return 0 if successful, -1 if not
+ */
+int h2o_configurator_scanf(h2o_configurator_command_t *cmd, yoml_t *node, const char *fmt, ...)
+ __attribute__((format(scanf, 3, 4)));
+/**
+ * interprets the configuration value and returns the index of the matched string within the candidate strings, or prints an error
+ * upon failure
+ * @param configurator configurator
+ * @param node configuration value
+ * @param candidates a comma-separated list of strings (should not contain whitespaces)
+ * @return index of the matched string within the given list, or -1 if none of them matched
+ */
+ssize_t h2o_configurator_get_one_of(h2o_configurator_command_t *cmd, yoml_t *node, const char *candidates);
+/**
+ * returns the absolute paths of supplementary commands
+ */
+char *h2o_configurator_get_cmd_path(const char *cmd);
+
+/**
+ * lib/handler/configurator/headers_util.c
+ */
+void h2o_configurator_define_headers_commands(h2o_globalconf_t *global_conf, h2o_configurator_t *conf, const char *prefix,
+ h2o_configurator_get_headers_commands_cb get_commands);
+
+void h2o_configurator__init_core(h2o_globalconf_t *conf);
+void h2o_configurator__dispose_configurators(h2o_globalconf_t *conf);
+
+#endif
diff --git a/debian/vendor-h2o/include/h2o/file.h b/debian/vendor-h2o/include/h2o/file.h
new file mode 100644
index 0000000..76c5ed6
--- /dev/null
+++ b/debian/vendor-h2o/include/h2o/file.h
@@ -0,0 +1,29 @@
+/*
+ * Copyright (c) 2015 DeNA Co., Ltd., Kazuho Oku
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+#ifndef h2o__file_h
+#define h2o__file_h
+
+#include "h2o/memory.h"
+
+h2o_iovec_t h2o_file_read(const char *fn);
+
+#endif
diff --git a/debian/vendor-h2o/include/h2o/filecache.h b/debian/vendor-h2o/include/h2o/filecache.h
new file mode 100644
index 0000000..a000c4c
--- /dev/null
+++ b/debian/vendor-h2o/include/h2o/filecache.h
@@ -0,0 +1,68 @@
+/*
+ * Copyright (c) 2015 DeNA Co., Ltd., Kazuho Oku
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+#ifndef h2o__filecache_h
+#define h2o__filecache_h
+
+#include <stddef.h>
+#include <sys/stat.h>
+#include <time.h>
+#include "h2o/linklist.h"
+#include "h2o/memory.h"
+#include "h2o/time_.h"
+
+#define H2O_FILECACHE_ETAG_MAXLEN (sizeof("\"deadbeef-deadbeefdeadbeef\"") - 1)
+
+typedef struct st_h2o_filecache_ref_t {
+ int fd;
+ size_t _refcnt;
+ h2o_linklist_t _lru;
+ union {
+ struct {
+ /* used if fd != -1 */
+ struct stat st;
+ struct {
+ struct tm gm;
+ char str[H2O_TIMESTR_RFC1123_LEN + 1];
+ } _last_modified;
+ struct {
+ char buf[H2O_FILECACHE_ETAG_MAXLEN + 1];
+ size_t len;
+ } _etag;
+ };
+ /* used if fd != -1 */
+ int open_err;
+ };
+ char _path[1];
+} h2o_filecache_ref_t;
+
+typedef struct st_h2o_filecache_t h2o_filecache_t;
+
+h2o_filecache_t *h2o_filecache_create(size_t capacity);
+void h2o_filecache_destroy(h2o_filecache_t *cache);
+void h2o_filecache_clear(h2o_filecache_t *cache);
+
+h2o_filecache_ref_t *h2o_filecache_open_file(h2o_filecache_t *cache, const char *path, int oflag);
+void h2o_filecache_close_file(h2o_filecache_ref_t *ref);
+struct tm *h2o_filecache_get_last_modified(h2o_filecache_ref_t *ref, char *outbuf);
+size_t h2o_filecache_get_etag(h2o_filecache_ref_t *ref, char *outbuf);
+
+#endif
diff --git a/debian/vendor-h2o/include/h2o/hostinfo.h b/debian/vendor-h2o/include/h2o/hostinfo.h
new file mode 100644
index 0000000..14ac30c
--- /dev/null
+++ b/debian/vendor-h2o/include/h2o/hostinfo.h
@@ -0,0 +1,91 @@
+/*
+ * Copyright (c) 2015 DeNA Co., Ltd., Kazuho Oku
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+#ifndef h2o__hostinfo_h
+#define h2o__hostinfo_h
+
+#include <arpa/inet.h>
+#include <netdb.h>
+#include <netinet/in.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/socket.h>
+#include <sys/types.h>
+#include "h2o/multithread.h"
+
+typedef struct st_h2o_hostinfo_getaddr_req_t h2o_hostinfo_getaddr_req_t;
+
+typedef void (*h2o_hostinfo_getaddr_cb)(h2o_hostinfo_getaddr_req_t *req, const char *errstr, struct addrinfo *res, void *cbdata);
+
+extern size_t h2o_hostinfo_max_threads;
+
+/**
+ * dispatches a (possibly) asynchronous hostname lookup
+ */
+h2o_hostinfo_getaddr_req_t *h2o_hostinfo_getaddr(h2o_multithread_receiver_t *receiver, h2o_iovec_t name, h2o_iovec_t serv,
+ int family, int socktype, int protocol, int flags, h2o_hostinfo_getaddr_cb cb,
+ void *cbdata);
+/**
+ *
+ */
+void h2o__hostinfo_getaddr_dispatch(h2o_hostinfo_getaddr_req_t *req);
+/**
+ * cancels the request
+ */
+void h2o_hostinfo_getaddr_cancel(h2o_hostinfo_getaddr_req_t *req);
+
+/**
+ * function that receives and dispatches the responses
+ */
+void h2o_hostinfo_getaddr_receiver(h2o_multithread_receiver_t *receiver, h2o_linklist_t *messages);
+
+/**
+ * select one entry at random from the response
+ */
+static struct addrinfo *h2o_hostinfo_select_one(struct addrinfo *res);
+
+/**
+ * equiv. to inet_pton(AF_INET4)
+ */
+int h2o_hostinfo_aton(h2o_iovec_t host, struct in_addr *addr);
+
+/* inline defs */
+
+inline struct addrinfo *h2o_hostinfo_select_one(struct addrinfo *res)
+{
+ if (res->ai_next == NULL)
+ return res;
+
+ /* count the number of candidates */
+ size_t i = 0;
+ struct addrinfo *ai = res;
+ do {
+ ++i;
+ } while ((ai = ai->ai_next) != NULL);
+
+ /* choose one, distributed by rand() :-p */
+ i = rand() % i;
+ for (ai = res; i != 0; ai = ai->ai_next, --i)
+ ;
+ return ai;
+}
+
+#endif
diff --git a/debian/vendor-h2o/include/h2o/http1.h b/debian/vendor-h2o/include/h2o/http1.h
new file mode 100644
index 0000000..cb9e939
--- /dev/null
+++ b/debian/vendor-h2o/include/h2o/http1.h
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2014 DeNA Co., Ltd.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+#ifndef h2o__http1_h
+#define h2o__http1_h
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef void (*h2o_http1_upgrade_cb)(void *user_data, h2o_socket_t *sock, size_t reqsize);
+
+extern const h2o_protocol_callbacks_t H2O_HTTP1_CALLBACKS;
+
+void h2o_http1_accept(h2o_accept_ctx_t *ctx, h2o_socket_t *sock, struct timeval connected_at);
+void h2o_http1_upgrade(h2o_req_t *req, h2o_iovec_t *inbufs, size_t inbufcnt, h2o_http1_upgrade_cb on_complete, void *user_data);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/debian/vendor-h2o/include/h2o/http1client.h b/debian/vendor-h2o/include/h2o/http1client.h
new file mode 100644
index 0000000..2439940
--- /dev/null
+++ b/debian/vendor-h2o/include/h2o/http1client.h
@@ -0,0 +1,82 @@
+/*
+ * Copyright (c) 2014 DeNA Co., Ltd.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+#ifndef h2o__http1client_h
+#define h2o__http1client_h
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include "h2o/memory.h"
+#include "h2o/socket.h"
+#include "h2o/socketpool.h"
+#include "h2o/timeout.h"
+#include "h2o/cache.h"
+
+typedef struct st_h2o_http1client_t h2o_http1client_t;
+
+struct st_h2o_header_t;
+typedef int (*h2o_http1client_body_cb)(h2o_http1client_t *client, const char *errstr);
+typedef h2o_http1client_body_cb (*h2o_http1client_head_cb)(h2o_http1client_t *client, const char *errstr, int minor_version,
+ int status, h2o_iovec_t msg, struct st_h2o_header_t *headers,
+ size_t num_headers, int rlen);
+typedef h2o_http1client_head_cb (*h2o_http1client_connect_cb)(h2o_http1client_t *client, const char *errstr, h2o_iovec_t **reqbufs,
+ size_t *reqbufcnt, int *method_is_head);
+typedef int (*h2o_http1client_informational_cb)(h2o_http1client_t *client, int minor_version, int status, h2o_iovec_t msg,
+ struct st_h2o_header_t *headers, size_t num_headers);
+
+typedef struct st_h2o_http1client_ctx_t {
+ h2o_loop_t *loop;
+ h2o_multithread_receiver_t *getaddr_receiver;
+ h2o_timeout_t *io_timeout;
+ h2o_timeout_t *websocket_timeout; /* NULL if upgrade to websocket is not allowed */
+ SSL_CTX *ssl_ctx;
+} h2o_http1client_ctx_t;
+
+struct st_h2o_http1client_t {
+ h2o_http1client_ctx_t *ctx;
+ struct {
+ h2o_socketpool_t *pool;
+ h2o_socketpool_connect_request_t *connect_req;
+ } sockpool;
+ struct {
+ char *server_name; /* non-null if ssl is to be used */
+ } ssl;
+ h2o_socket_t *sock;
+ void *data;
+ h2o_http1client_informational_cb informational_cb;
+};
+
+extern const char *const h2o_http1client_error_is_eos;
+
+void h2o_http1client_connect(h2o_http1client_t **client, void *data, h2o_http1client_ctx_t *ctx, h2o_iovec_t host, uint16_t port,
+ int is_ssl, h2o_http1client_connect_cb cb);
+void h2o_http1client_connect_with_pool(h2o_http1client_t **client, void *data, h2o_http1client_ctx_t *ctx,
+ h2o_socketpool_t *sockpool, h2o_http1client_connect_cb cb);
+void h2o_http1client_cancel(h2o_http1client_t *client);
+h2o_socket_t *h2o_http1client_steal_socket(h2o_http1client_t *client);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/debian/vendor-h2o/include/h2o/http2.h b/debian/vendor-h2o/include/h2o/http2.h
new file mode 100644
index 0000000..567e77d
--- /dev/null
+++ b/debian/vendor-h2o/include/h2o/http2.h
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2014 DeNA Co., Ltd.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+#ifndef h2o__http2_h
+#define h2o__http2_h
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+extern const char *h2o_http2_npn_protocols;
+extern const h2o_iovec_t *h2o_http2_alpn_protocols;
+
+extern const h2o_protocol_callbacks_t H2O_HTTP2_CALLBACKS;
+
+#define H2O_HTTP2_SETTINGS_HEADER_TABLE_SIZE 1
+#define H2O_HTTP2_SETTINGS_ENABLE_PUSH 2
+#define H2O_HTTP2_SETTINGS_MAX_CONCURRENT_STREAMS 3
+#define H2O_HTTP2_SETTINGS_INITIAL_WINDOW_SIZE 4
+#define H2O_HTTP2_SETTINGS_MAX_FRAME_SIZE 5
+#define H2O_HTTP2_SETTINGS_MAX_HEADER_LIST_SIZE 6
+
+typedef struct st_h2o_http2_settings_t {
+ uint32_t header_table_size;
+ uint32_t enable_push;
+ uint32_t max_concurrent_streams;
+ uint32_t initial_window_size;
+ uint32_t max_frame_size;
+} h2o_http2_settings_t;
+
+extern const h2o_http2_settings_t H2O_HTTP2_SETTINGS_DEFAULT;
+extern const h2o_http2_settings_t H2O_HTTP2_SETTINGS_HOST;
+
+typedef struct st_h2o_http2_priority_t {
+ int exclusive;
+ uint32_t dependency;
+ uint16_t weight;
+} h2o_http2_priority_t;
+
+extern const h2o_http2_priority_t h2o_http2_default_priority;
+
+void h2o_http2_accept(h2o_accept_ctx_t *ctx, h2o_socket_t *sock, struct timeval connected_at);
+int h2o_http2_handle_upgrade(h2o_req_t *req, struct timeval connected_at);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/debian/vendor-h2o/include/h2o/http2_casper.h b/debian/vendor-h2o/include/h2o/http2_casper.h
new file mode 100644
index 0000000..dd6ea24
--- /dev/null
+++ b/debian/vendor-h2o/include/h2o/http2_casper.h
@@ -0,0 +1,56 @@
+/*
+ * Copyright (c) 2015 DeNA Co., Ltd., Kazuho Oku
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+#ifndef h2o__http2__casper_h
+#define h2o__http2__casper_h
+
+#include <stddef.h>
+#include <stdlib.h>
+#include "h2o/memory.h"
+
+typedef struct st_h2o_http2_casper_t h2o_http2_casper_t;
+
+/**
+ * creates an object with provided parameters
+ */
+h2o_http2_casper_t *h2o_http2_casper_create(unsigned capacity_bits, unsigned remainder_bits);
+/**
+ * destroys the object and resources associated to it
+ */
+void h2o_http2_casper_destroy(h2o_http2_casper_t *casper);
+/**
+ * returns the number of keys stored
+ */
+size_t h2o_http2_casper_num_entries(h2o_http2_casper_t *casper);
+/**
+ * checks if a key is (was) marked as cached at the moment the fuction is invoked
+ */
+int h2o_http2_casper_lookup(h2o_http2_casper_t *casper, const char *path, size_t path_len, int set);
+/**
+ * consumes the `Cookie` headers in requests and updates the structure
+ */
+void h2o_http2_casper_consume_cookie(h2o_http2_casper_t *casper, const char *cookie, size_t cookie_len);
+/**
+ * returns the value of the `Set-Cookie` header that should be sent to the client
+ */
+h2o_iovec_t h2o_http2_casper_get_cookie(h2o_http2_casper_t *casper);
+
+#endif
diff --git a/debian/vendor-h2o/include/h2o/http2_internal.h b/debian/vendor-h2o/include/h2o/http2_internal.h
new file mode 100644
index 0000000..b9cf400
--- /dev/null
+++ b/debian/vendor-h2o/include/h2o/http2_internal.h
@@ -0,0 +1,512 @@
+/*
+ * Copyright (c) 2014,2015 DeNA Co., Ltd.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+#ifndef h2o__http2__internal_h
+#define h2o__http2__internal_h
+
+#include <assert.h>
+#include <stdint.h>
+#include "khash.h"
+#include "h2o/cache.h"
+#include "h2o/http2_casper.h"
+#include "h2o/cache_digests.h"
+#include "h2o/http2_scheduler.h"
+
+typedef struct st_h2o_http2_conn_t h2o_http2_conn_t;
+typedef struct st_h2o_http2_stream_t h2o_http2_stream_t;
+
+#define H2O_HTTP2_DEFAULT_OUTBUF_SIZE 81920 /* the target size of each write call; connection flow control window + alpha */
+#define H2O_HTTP2_DEFAULT_OUTBUF_SOFT_MAX_SIZE 524288 /* 512KB; stops reading if size exceeds this value */
+
+/* hpack */
+
+#define H2O_HTTP2_ENCODE_INT_MAX_LENGTH 5
+
+typedef struct st_h2o_hpack_header_table_t {
+ /* ring buffer */
+ struct st_h2o_hpack_header_table_entry_t *entries;
+ size_t num_entries, entry_capacity, entry_start_index;
+ /* size and capacities are 32+name_len+value_len (as defined by hpack spec.) */
+ size_t hpack_size;
+ size_t hpack_capacity; /* the value set by SETTINGS_HEADER_TABLE_SIZE _and_ dynamic table size update */
+ size_t hpack_max_capacity; /* the value set by SETTINGS_HEADER_TABLE_SIZE */
+} h2o_hpack_header_table_t;
+
+typedef struct st_h2o_hpack_header_table_entry_t {
+ h2o_iovec_t *name;
+ h2o_iovec_t *value;
+ const char *err_desc; /* the recorded soft error description */
+} h2o_hpack_header_table_entry_t;
+
+#define H2O_HPACK_PARSE_HEADERS_METHOD_EXISTS 1
+#define H2O_HPACK_PARSE_HEADERS_SCHEME_EXISTS 2
+#define H2O_HPACK_PARSE_HEADERS_PATH_EXISTS 4
+#define H2O_HPACK_PARSE_HEADERS_AUTHORITY_EXISTS 8
+
+void h2o_hpack_dispose_header_table(h2o_hpack_header_table_t *header_table);
+int h2o_hpack_parse_headers(h2o_req_t *req, h2o_hpack_header_table_t *header_table, const uint8_t *src, size_t len,
+ int *pseudo_header_exists_map, size_t *content_length, h2o_cache_digests_t **digests,
+ const char **err_desc);
+size_t h2o_hpack_encode_string(uint8_t *dst, const char *s, size_t len);
+void h2o_hpack_flatten_request(h2o_buffer_t **buf, h2o_hpack_header_table_t *header_table, uint32_t stream_id,
+ size_t max_frame_size, h2o_req_t *req, uint32_t parent_stream_id);
+void h2o_hpack_flatten_response(h2o_buffer_t **buf, h2o_hpack_header_table_t *header_table, uint32_t stream_id,
+ size_t max_frame_size, h2o_res_t *res, h2o_timestamp_t *ts, const h2o_iovec_t *server_name,
+ size_t content_length);
+static h2o_hpack_header_table_entry_t *h2o_hpack_header_table_get(h2o_hpack_header_table_t *table, size_t index);
+
+/* frames */
+
+#define H2O_HTTP2_FRAME_HEADER_SIZE 9
+
+#define H2O_HTTP2_FRAME_TYPE_DATA 0
+#define H2O_HTTP2_FRAME_TYPE_HEADERS 1
+#define H2O_HTTP2_FRAME_TYPE_PRIORITY 2
+#define H2O_HTTP2_FRAME_TYPE_RST_STREAM 3
+#define H2O_HTTP2_FRAME_TYPE_SETTINGS 4
+#define H2O_HTTP2_FRAME_TYPE_PUSH_PROMISE 5
+#define H2O_HTTP2_FRAME_TYPE_PING 6
+#define H2O_HTTP2_FRAME_TYPE_GOAWAY 7
+#define H2O_HTTP2_FRAME_TYPE_WINDOW_UPDATE 8
+#define H2O_HTTP2_FRAME_TYPE_CONTINUATION 9
+
+#define H2O_HTTP2_FRAME_FLAG_END_STREAM 0x1
+#define H2O_HTTP2_FRAME_FLAG_ACK 0x1
+#define H2O_HTTP2_FRAME_FLAG_END_HEADERS 0x4
+#define H2O_HTTP2_FRAME_FLAG_PADDED 0x8
+#define H2O_HTTP2_FRAME_FLAG_PRIORITY 0x20
+
+typedef struct st_h2o_http2_frame_t {
+ uint32_t length;
+ uint8_t type;
+ uint8_t flags;
+ uint32_t stream_id;
+ const uint8_t *payload;
+} h2o_http2_frame_t;
+
+typedef struct st_h2o_http2_data_payload_t {
+ const uint8_t *data;
+ size_t length;
+} h2o_http2_data_payload_t;
+
+typedef struct st_h2o_http2_headers_payload_t {
+ h2o_http2_priority_t priority;
+ const uint8_t *headers;
+ size_t headers_len;
+} h2o_http2_headers_payload_t;
+
+typedef struct st_h2o_http2_rst_stream_payload_t {
+ uint32_t error_code;
+} h2o_http2_rst_stream_payload_t;
+
+typedef struct st_h2o_http2_ping_payload_t {
+ uint8_t data[8];
+} h2o_http2_ping_payload_t;
+
+typedef struct st_h2o_http2_goaway_payload_t {
+ uint32_t last_stream_id;
+ uint32_t error_code;
+ h2o_iovec_t debug_data;
+} h2o_http2_goaway_payload_t;
+
+typedef struct st_h2o_http2_window_update_payload_t {
+ uint32_t window_size_increment;
+} h2o_http2_window_update_payload_t;
+
+typedef struct st_h2o_http2_window_t {
+ ssize_t _avail;
+} h2o_http2_window_t;
+
+typedef enum enum_h2o_http2_stream_state_t {
+ H2O_HTTP2_STREAM_STATE_IDLE,
+ H2O_HTTP2_STREAM_STATE_RECV_HEADERS,
+ H2O_HTTP2_STREAM_STATE_RECV_BODY,
+ H2O_HTTP2_STREAM_STATE_REQ_PENDING,
+ H2O_HTTP2_STREAM_STATE_SEND_HEADERS,
+ H2O_HTTP2_STREAM_STATE_SEND_BODY,
+ H2O_HTTP2_STREAM_STATE_SEND_BODY_IS_FINAL,
+ H2O_HTTP2_STREAM_STATE_END_STREAM
+} h2o_http2_stream_state_t;
+
+typedef struct st_h2o_http2_conn_num_streams_t {
+ uint32_t open;
+ uint32_t half_closed;
+ uint32_t send_body;
+} h2o_http2_conn_num_streams_t;
+
+struct st_h2o_http2_stream_t {
+ uint32_t stream_id;
+ h2o_ostream_t _ostr_final;
+ h2o_http2_stream_state_t state;
+ h2o_http2_window_t output_window;
+ h2o_http2_window_t input_window;
+ h2o_http2_priority_t received_priority;
+ h2o_buffer_t *_req_body; /* NULL unless request body IS expected */
+ size_t _expected_content_length; /* SIZE_MAX if unknown */
+ H2O_VECTOR(h2o_iovec_t) _data;
+ h2o_ostream_pull_cb _pull_cb;
+ h2o_http2_conn_num_streams_t *_num_streams_slot; /* points http2_conn_t::num_streams::* in which the stream is counted */
+ h2o_cache_digests_t *cache_digests;
+ union {
+ struct {
+ uint32_t parent_stream_id;
+ unsigned promise_sent : 1;
+ } push;
+ struct {
+ unsigned casper_is_ready : 1;
+ } pull;
+ };
+ /* references governed by connection.c for handling various things */
+ struct {
+ h2o_linklist_t link;
+ h2o_http2_scheduler_openref_t scheduler;
+ } _refs;
+ unsigned reset_by_peer : 1;
+ h2o_send_state_t send_state; /* state of the ostream, only used in push mode */
+ /* placed at last since it is large and has it's own ctor */
+ h2o_req_t req;
+};
+
+KHASH_MAP_INIT_INT64(h2o_http2_stream_t, h2o_http2_stream_t *)
+
+typedef enum enum_h2o_http2_conn_state_t {
+ H2O_HTTP2_CONN_STATE_OPEN, /* accepting new connections */
+ H2O_HTTP2_CONN_STATE_HALF_CLOSED, /* no more accepting new streams */
+ H2O_HTTP2_CONN_STATE_IS_CLOSING /* nothing should be sent */
+} h2o_http2_conn_state_t;
+
+struct st_h2o_http2_conn_t {
+ h2o_conn_t super;
+ h2o_socket_t *sock;
+ /* settings */
+ h2o_http2_settings_t peer_settings;
+ /* streams */
+ khash_t(h2o_http2_stream_t) * streams;
+ struct {
+ uint32_t max_open;
+ uint32_t max_processed;
+ } pull_stream_ids;
+ struct {
+ uint32_t max_open;
+ } push_stream_ids;
+ struct {
+ h2o_http2_conn_num_streams_t priority;
+ h2o_http2_conn_num_streams_t pull;
+ h2o_http2_conn_num_streams_t push;
+ } num_streams;
+ /* internal */
+ h2o_http2_scheduler_node_t scheduler;
+ h2o_http2_conn_state_t state;
+ h2o_linklist_t _conns; /* linklist to h2o_context_t::http2._conns */
+ ssize_t (*_read_expect)(h2o_http2_conn_t *conn, const uint8_t *src, size_t len, const char **err_desc);
+ h2o_buffer_t *_http1_req_input; /* contains data referred to by original request via HTTP/1.1 */
+ h2o_hpack_header_table_t _input_header_table;
+ h2o_http2_window_t _input_window;
+ h2o_hpack_header_table_t _output_header_table;
+ h2o_linklist_t _pending_reqs; /* list of h2o_http2_stream_t that contain pending requests */
+ h2o_timeout_entry_t _timeout_entry;
+ h2o_buffer_t *_headers_unparsed; /* for temporary storing HEADERS|CONTINUATION frames without END_HEADERS flag set */
+ struct {
+ h2o_buffer_t *buf;
+ h2o_buffer_t *buf_in_flight;
+ h2o_linklist_t streams_to_proceed;
+ h2o_timeout_entry_t timeout_entry;
+ h2o_http2_window_t window;
+ } _write;
+ h2o_cache_t *push_memo;
+ h2o_http2_casper_t *casper;
+ /**
+ * DoS mitigation; the idea here is to delay processing requests when observing suspicious behavior
+ */
+ struct {
+ h2o_timeout_entry_t process_delay;
+ size_t reset_budget; /* RST_STREAM frames are considered suspicious when this value goes down to zero */
+ } dos_mitigation;
+};
+
+int h2o_http2_update_peer_settings(h2o_http2_settings_t *settings, const uint8_t *src, size_t len, const char **err_desc);
+
+/* frames */
+uint8_t *h2o_http2_encode_frame_header(uint8_t *dst, size_t length, uint8_t type, uint8_t flags, int32_t stream_id);
+
+#define h2o_http2_encode_rst_stream_frame(buf, stream_id, errnum) \
+ h2o_http2__encode_rst_stream_frame(buf, stream_id, (H2O_BUILD_ASSERT((errnum) > 0), errnum))
+
+void h2o_http2__encode_rst_stream_frame(h2o_buffer_t **buf, uint32_t stream_id, int errnum);
+void h2o_http2_encode_ping_frame(h2o_buffer_t **buf, int is_ack, const uint8_t *data);
+void h2o_http2_encode_goaway_frame(h2o_buffer_t **buf, uint32_t last_stream_id, int errnum, h2o_iovec_t additional_data);
+void h2o_http2_encode_window_update_frame(h2o_buffer_t **buf, uint32_t stream_id, int32_t window_size_increment);
+ssize_t h2o_http2_decode_frame(h2o_http2_frame_t *frame, const uint8_t *src, size_t len, const h2o_http2_settings_t *host_settings,
+ const char **err_desc);
+int h2o_http2_decode_data_payload(h2o_http2_data_payload_t *payload, const h2o_http2_frame_t *frame, const char **err_desc);
+int h2o_http2_decode_headers_payload(h2o_http2_headers_payload_t *payload, const h2o_http2_frame_t *frame, const char **err_desc);
+int h2o_http2_decode_priority_payload(h2o_http2_priority_t *payload, const h2o_http2_frame_t *frame, const char **err_desc);
+int h2o_http2_decode_rst_stream_payload(h2o_http2_rst_stream_payload_t *payload, const h2o_http2_frame_t *frame,
+ const char **err_desc);
+int h2o_http2_decode_ping_payload(h2o_http2_ping_payload_t *payload, const h2o_http2_frame_t *frame, const char **err_desc);
+int h2o_http2_decode_goaway_payload(h2o_http2_goaway_payload_t *payload, const h2o_http2_frame_t *frame, const char **err_desc);
+int h2o_http2_decode_window_update_payload(h2o_http2_window_update_payload_t *paylaod, const h2o_http2_frame_t *frame,
+ const char **err_desc, int *err_is_stream_level);
+
+/* connection */
+void h2o_http2_conn_register_stream(h2o_http2_conn_t *conn, h2o_http2_stream_t *stream);
+void h2o_http2_conn_unregister_stream(h2o_http2_conn_t *conn, h2o_http2_stream_t *stream);
+static h2o_http2_stream_t *h2o_http2_conn_get_stream(h2o_http2_conn_t *conn, uint32_t stream_id);
+void h2o_http2_conn_push_path(h2o_http2_conn_t *conn, h2o_iovec_t path, h2o_http2_stream_t *src_stream);
+void h2o_http2_conn_request_write(h2o_http2_conn_t *conn);
+void h2o_http2_conn_register_for_proceed_callback(h2o_http2_conn_t *conn, h2o_http2_stream_t *stream);
+static ssize_t h2o_http2_conn_get_buffer_window(h2o_http2_conn_t *conn);
+static void h2o_http2_conn_init_casper(h2o_http2_conn_t *conn, unsigned capacity_bits);
+
+/* stream */
+static int h2o_http2_stream_is_push(uint32_t stream_id);
+h2o_http2_stream_t *h2o_http2_stream_open(h2o_http2_conn_t *conn, uint32_t stream_id, h2o_req_t *src_req,
+ const h2o_http2_priority_t *received_priority);
+static void h2o_http2_stream_update_open_slot(h2o_http2_stream_t *stream, h2o_http2_conn_num_streams_t *slot);
+static void h2o_http2_stream_set_state(h2o_http2_conn_t *conn, h2o_http2_stream_t *stream, h2o_http2_stream_state_t new_state);
+static void h2o_http2_stream_prepare_for_request(h2o_http2_conn_t *conn, h2o_http2_stream_t *stream);
+void h2o_http2_stream_close(h2o_http2_conn_t *conn, h2o_http2_stream_t *stream);
+void h2o_http2_stream_reset(h2o_http2_conn_t *conn, h2o_http2_stream_t *stream);
+void h2o_http2_stream_send_pending_data(h2o_http2_conn_t *conn, h2o_http2_stream_t *stream);
+static int h2o_http2_stream_has_pending_data(h2o_http2_stream_t *stream);
+void h2o_http2_stream_proceed(h2o_http2_conn_t *conn, h2o_http2_stream_t *stream);
+static void h2o_http2_stream_send_push_promise(h2o_http2_conn_t *conn, h2o_http2_stream_t *stream);
+
+/* misc */
+static void h2o_http2_window_init(h2o_http2_window_t *window, const h2o_http2_settings_t *peer_settings);
+static int h2o_http2_window_update(h2o_http2_window_t *window, ssize_t delta);
+static ssize_t h2o_http2_window_get_window(h2o_http2_window_t *window);
+static void h2o_http2_window_consume_window(h2o_http2_window_t *window, size_t bytes);
+
+static uint16_t h2o_http2_decode16u(const uint8_t *src);
+static uint32_t h2o_http2_decode24u(const uint8_t *src);
+static uint32_t h2o_http2_decode32u(const uint8_t *src);
+static uint8_t *h2o_http2_encode24u(uint8_t *dst, uint32_t value);
+static uint8_t *h2o_http2_encode32u(uint8_t *dst, uint32_t value);
+
+h2o_http2_debug_state_t *h2o_http2_get_debug_state(h2o_req_t *req, int hpack_enabled);
+
+/* inline definitions */
+
+inline void h2o_http2_window_init(h2o_http2_window_t *window, const h2o_http2_settings_t *peer_settings)
+{
+ window->_avail = peer_settings->initial_window_size;
+}
+
+inline int h2o_http2_window_update(h2o_http2_window_t *window, ssize_t delta)
+{
+ ssize_t v = window->_avail + delta;
+ if (v > INT32_MAX)
+ return -1;
+ window->_avail = v;
+ return 0;
+}
+
+inline ssize_t h2o_http2_window_get_window(h2o_http2_window_t *window)
+{
+ return window->_avail;
+}
+
+inline void h2o_http2_window_consume_window(h2o_http2_window_t *window, size_t bytes)
+{
+ window->_avail -= bytes;
+}
+
+inline h2o_http2_stream_t *h2o_http2_conn_get_stream(h2o_http2_conn_t *conn, uint32_t stream_id)
+{
+ khiter_t iter = kh_get(h2o_http2_stream_t, conn->streams, stream_id);
+ if (iter != kh_end(conn->streams))
+ return kh_val(conn->streams, iter);
+ return NULL;
+}
+
+inline int h2o_http2_stream_is_push(uint32_t stream_id)
+{
+ return stream_id % 2 == 0;
+}
+
+inline ssize_t h2o_http2_conn_get_buffer_window(h2o_http2_conn_t *conn)
+{
+ ssize_t ret, winsz;
+ size_t capacity, cwnd_left;
+
+ capacity = conn->_write.buf->capacity;
+ if ((cwnd_left = h2o_socket_prepare_for_latency_optimized_write(
+ conn->sock, &conn->super.ctx->globalconf->http2.latency_optimization)) < capacity) {
+ capacity = cwnd_left;
+ if (capacity < conn->_write.buf->size)
+ return 0;
+ }
+
+ ret = capacity - conn->_write.buf->size;
+ if (ret < H2O_HTTP2_FRAME_HEADER_SIZE)
+ return 0;
+ ret -= H2O_HTTP2_FRAME_HEADER_SIZE;
+ winsz = h2o_http2_window_get_window(&conn->_write.window);
+ if (winsz < ret)
+ ret = winsz;
+ return ret;
+}
+
+inline void h2o_http2_conn_init_casper(h2o_http2_conn_t *conn, unsigned capacity_bits)
+{
+ assert(conn->casper == NULL);
+ conn->casper = h2o_http2_casper_create(capacity_bits, 6);
+}
+
+inline void h2o_http2_stream_update_open_slot(h2o_http2_stream_t *stream, h2o_http2_conn_num_streams_t *slot)
+{
+ --stream->_num_streams_slot->open;
+ ++slot->open;
+ stream->_num_streams_slot = slot;
+}
+
+inline void h2o_http2_stream_set_state(h2o_http2_conn_t *conn, h2o_http2_stream_t *stream, h2o_http2_stream_state_t new_state)
+{
+ switch (new_state) {
+ case H2O_HTTP2_STREAM_STATE_IDLE:
+ assert(!"FIXME");
+ break;
+ case H2O_HTTP2_STREAM_STATE_RECV_HEADERS:
+ assert(stream->state == H2O_HTTP2_STREAM_STATE_IDLE);
+ if (h2o_http2_stream_is_push(stream->stream_id))
+ h2o_http2_stream_update_open_slot(stream, &conn->num_streams.push);
+ else
+ h2o_http2_stream_update_open_slot(stream, &conn->num_streams.pull);
+ stream->state = new_state;
+ stream->req.timestamps.request_begin_at = *h2o_get_timestamp(conn->super.ctx, NULL, NULL);
+ break;
+ case H2O_HTTP2_STREAM_STATE_RECV_BODY:
+ stream->state = new_state;
+ stream->req.timestamps.request_body_begin_at = *h2o_get_timestamp(conn->super.ctx, NULL, NULL);
+ break;
+ case H2O_HTTP2_STREAM_STATE_REQ_PENDING:
+ stream->state = new_state;
+ break;
+ case H2O_HTTP2_STREAM_STATE_SEND_HEADERS:
+ assert(stream->state == H2O_HTTP2_STREAM_STATE_REQ_PENDING);
+ ++stream->_num_streams_slot->half_closed;
+ stream->state = new_state;
+ break;
+ case H2O_HTTP2_STREAM_STATE_SEND_BODY:
+ stream->state = new_state;
+ ++stream->_num_streams_slot->send_body;
+ stream->req.timestamps.response_start_at = *h2o_get_timestamp(conn->super.ctx, NULL, NULL);
+ break;
+ case H2O_HTTP2_STREAM_STATE_SEND_BODY_IS_FINAL:
+ assert(stream->state == H2O_HTTP2_STREAM_STATE_SEND_BODY);
+ stream->state = new_state;
+ break;
+ case H2O_HTTP2_STREAM_STATE_END_STREAM:
+ switch (stream->state) {
+ case H2O_HTTP2_STREAM_STATE_IDLE:
+ case H2O_HTTP2_STREAM_STATE_RECV_BODY:
+ case H2O_HTTP2_STREAM_STATE_RECV_HEADERS:
+ break;
+ case H2O_HTTP2_STREAM_STATE_REQ_PENDING:
+ break;
+ case H2O_HTTP2_STREAM_STATE_SEND_HEADERS:
+ --stream->_num_streams_slot->half_closed;
+ break;
+ case H2O_HTTP2_STREAM_STATE_SEND_BODY:
+ case H2O_HTTP2_STREAM_STATE_SEND_BODY_IS_FINAL:
+ --stream->_num_streams_slot->half_closed;
+ --stream->_num_streams_slot->send_body;
+ break;
+ case H2O_HTTP2_STREAM_STATE_END_STREAM:
+ assert(!"FIXME");
+ break;
+ }
+ stream->state = new_state;
+ stream->req.timestamps.response_end_at = *h2o_get_timestamp(conn->super.ctx, NULL, NULL);
+ --stream->_num_streams_slot->open;
+ stream->_num_streams_slot = NULL;
+ break;
+ }
+}
+
+inline void h2o_http2_stream_prepare_for_request(h2o_http2_conn_t *conn, h2o_http2_stream_t *stream)
+{
+ assert(h2o_http2_scheduler_is_open(&stream->_refs.scheduler));
+
+ /* adjust max-open */
+ uint32_t *max_open =
+ h2o_http2_stream_is_push(stream->stream_id) ? &conn->push_stream_ids.max_open : &conn->pull_stream_ids.max_open;
+ if (*max_open < stream->stream_id)
+ *max_open = stream->stream_id;
+ h2o_http2_stream_set_state(conn, stream, H2O_HTTP2_STREAM_STATE_RECV_HEADERS);
+ h2o_http2_window_init(&stream->output_window, &conn->peer_settings);
+}
+
+inline int h2o_http2_stream_has_pending_data(h2o_http2_stream_t *stream)
+{
+ return stream->_data.size != 0;
+}
+
+inline void h2o_http2_stream_send_push_promise(h2o_http2_conn_t *conn, h2o_http2_stream_t *stream)
+{
+ assert(!stream->push.promise_sent);
+ h2o_hpack_flatten_request(&conn->_write.buf, &conn->_output_header_table, stream->stream_id, conn->peer_settings.max_frame_size,
+ &stream->req, stream->push.parent_stream_id);
+ stream->push.promise_sent = 1;
+}
+
+inline uint16_t h2o_http2_decode16u(const uint8_t *src)
+{
+ return (uint16_t)src[0] << 8 | src[1];
+}
+
+inline uint32_t h2o_http2_decode24u(const uint8_t *src)
+{
+ return (uint32_t)src[0] << 16 | (uint32_t)src[1] << 8 | src[2];
+}
+
+inline uint32_t h2o_http2_decode32u(const uint8_t *src)
+{
+ return (uint32_t)src[0] << 24 | (uint32_t)src[1] << 16 | (uint32_t)src[2] << 8 | src[3];
+}
+
+inline uint8_t *h2o_http2_encode24u(uint8_t *dst, uint32_t value)
+{
+ *dst++ = value >> 16;
+ *dst++ = value >> 8;
+ *dst++ = value;
+ return dst;
+}
+
+inline uint8_t *h2o_http2_encode32u(uint8_t *dst, uint32_t value)
+{
+ *dst++ = value >> 24;
+ *dst++ = value >> 16;
+ *dst++ = value >> 8;
+ *dst++ = value;
+ return dst;
+}
+
+inline h2o_hpack_header_table_entry_t *h2o_hpack_header_table_get(h2o_hpack_header_table_t *table, size_t index)
+{
+ size_t entry_index = (index + table->entry_start_index) % table->entry_capacity;
+ struct st_h2o_hpack_header_table_entry_t *entry = table->entries + entry_index;
+ assert(entry->name != NULL);
+ return entry;
+}
+
+#endif
diff --git a/debian/vendor-h2o/include/h2o/http2_scheduler.h b/debian/vendor-h2o/include/h2o/http2_scheduler.h
new file mode 100644
index 0000000..f0a7d6e
--- /dev/null
+++ b/debian/vendor-h2o/include/h2o/http2_scheduler.h
@@ -0,0 +1,134 @@
+/*
+ * Copyright (c) 2015 DeNA Co., Ltd.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+#ifndef h2o__http2__scheduler_h
+#define h2o__http2__scheduler_h
+
+#include <assert.h>
+#include "h2o/linklist.h"
+#include "h2o/memory.h"
+
+typedef struct st_h2o_http2_scheduler_queue_node_t {
+ h2o_linklist_t _link;
+ size_t _deficit;
+} h2o_http2_scheduler_queue_node_t;
+
+typedef struct st_h2o_http2_scheduler_queue_t h2o_http2_scheduler_queue_t;
+
+/**
+ * resembles a node in the dependency tree; i.e. assigned for each HTTP/2 stream (as a member of openref), or the root of the tree
+ * associated to the connection
+ */
+typedef struct st_h2o_http2_scheduler_node_t {
+ struct st_h2o_http2_scheduler_node_t *_parent; /* NULL if root */
+ h2o_linklist_t _all_refs; /* list of nodes */
+ h2o_http2_scheduler_queue_t *_queue; /* priority list (NULL if _all_refs is empty) */
+} h2o_http2_scheduler_node_t;
+
+/**
+ * the entry to be scheduled; is assigned for every HTTP/2 stream.
+ */
+typedef struct st_h2o_http2_scheduler_openref_t {
+ h2o_http2_scheduler_node_t node;
+ uint16_t weight;
+ h2o_linklist_t _all_link; /* linked to _all_refs */
+ size_t _active_cnt; /* COUNT(active_streams_in_dependents) + _self_is_active */
+ int _self_is_active;
+ h2o_http2_scheduler_queue_node_t _queue_node;
+} h2o_http2_scheduler_openref_t;
+
+/**
+ * callback called by h2o_http2_scheduler_run.
+ * @param ref reference to an active stream that should consume resource
+ * @param still_is_active [out] flag to indicate whether the ref should still be marked as active after returning from the function
+ * @param cb_arg value of cb_arg passed to h2o_http2_scheduler_run
+ * @return non-zero value to stop traversing through the tree, or 0 to continue
+ */
+typedef int (*h2o_http2_scheduler_run_cb)(h2o_http2_scheduler_openref_t *ref, int *still_is_active, void *cb_arg);
+
+/**
+ *
+ */
+void h2o_http2_scheduler_init(h2o_http2_scheduler_node_t *root);
+
+/**
+ * disposes of the scheduler. All open references belonging to the node must be closed before calling this functions.
+ */
+void h2o_http2_scheduler_dispose(h2o_http2_scheduler_node_t *root);
+/**
+ * opens a reference with given parent as its dependency
+ */
+void h2o_http2_scheduler_open(h2o_http2_scheduler_openref_t *ref, h2o_http2_scheduler_node_t *parent, uint16_t weight,
+ int exclusive);
+/**
+ * closes a reference. All the dependents are raised to become the dependents of the parent of the reference being closed.
+ */
+void h2o_http2_scheduler_close(h2o_http2_scheduler_openref_t *ref);
+/**
+ * reprioritizes the reference.
+ */
+void h2o_http2_scheduler_rebind(h2o_http2_scheduler_openref_t *ref, h2o_http2_scheduler_node_t *new_parent, uint16_t weight,
+ int exclusive);
+/**
+ * tests if the ref is open
+ */
+static int h2o_http2_scheduler_is_open(h2o_http2_scheduler_openref_t *ref);
+/**
+ * returns weight associated to the reference
+ */
+static uint16_t h2o_http2_scheduler_get_weight(h2o_http2_scheduler_openref_t *ref);
+/**
+ * returns the parent
+ */
+static h2o_http2_scheduler_node_t *h2o_http2_scheduler_get_parent(h2o_http2_scheduler_openref_t *ref);
+/**
+ * activates a reference so that it would be passed back as the argument to the callback of the h2o_http2_scheduler_run function
+ * if any resource should be allocated
+ */
+void h2o_http2_scheduler_activate(h2o_http2_scheduler_openref_t *ref);
+/**
+ * calls the callback of the references linked to the dependency tree one by one, in the order defined by the dependency and the
+ * weight.
+ */
+int h2o_http2_scheduler_run(h2o_http2_scheduler_node_t *root, h2o_http2_scheduler_run_cb cb, void *cb_arg);
+/**
+ * returns if there are any active entries nodes in the scheduler (may have false positives, but no false negatives)
+ */
+int h2o_http2_scheduler_is_active(h2o_http2_scheduler_node_t *root);
+
+/* inline definitions */
+
+inline int h2o_http2_scheduler_is_open(h2o_http2_scheduler_openref_t *ref)
+{
+ return h2o_linklist_is_linked(&ref->_all_link);
+}
+
+inline uint16_t h2o_http2_scheduler_get_weight(h2o_http2_scheduler_openref_t *ref)
+{
+ return ref->weight;
+}
+
+inline h2o_http2_scheduler_node_t *h2o_http2_scheduler_get_parent(h2o_http2_scheduler_openref_t *ref)
+{
+ return ref->node._parent;
+}
+
+#endif
diff --git a/debian/vendor-h2o/include/h2o/linklist.h b/debian/vendor-h2o/include/h2o/linklist.h
new file mode 100644
index 0000000..eb7fd10
--- /dev/null
+++ b/debian/vendor-h2o/include/h2o/linklist.h
@@ -0,0 +1,119 @@
+/*
+ * Copyright (c) 2014 DeNA Co., Ltd.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+#ifndef h2o__linklist_h
+#define h2o__linklist_h
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <assert.h>
+#include <stddef.h>
+
+/**
+ * linklist
+ * The structure is used to represent both nodes and the head of the list.
+ * Nodes should be zero-filled upon initialization.
+ * Heads should be initialized by calling h2o_linklist_init_anchor.
+ */
+typedef struct st_h2o_linklist_t {
+ struct st_h2o_linklist_t *next;
+ struct st_h2o_linklist_t *prev;
+} h2o_linklist_t;
+
+/**
+ * initializes the anchor (i.e. head) of a linked list
+ */
+static void h2o_linklist_init_anchor(h2o_linklist_t *anchor);
+/**
+ * tests if the list is empty
+ */
+static int h2o_linklist_is_empty(h2o_linklist_t *anchor);
+/**
+ * tests if the node is linked to a list
+ */
+static int h2o_linklist_is_linked(h2o_linklist_t *node);
+/**
+ * inserts a node to the linked list
+ * @param pos insert position; the node will be inserted before pos
+ * @param node the node to be inserted
+ */
+static void h2o_linklist_insert(h2o_linklist_t *pos, h2o_linklist_t *node);
+/**
+ * inserts all the elements of list before pos (list becomes empty)
+ */
+static void h2o_linklist_insert_list(h2o_linklist_t *pos, h2o_linklist_t *list);
+/**
+ * unlinks a node from the linked list
+ */
+static void h2o_linklist_unlink(h2o_linklist_t *node);
+
+/* inline defs */
+
+inline void h2o_linklist_init_anchor(h2o_linklist_t *anchor)
+{
+ anchor->next = anchor->prev = anchor;
+}
+
+inline int h2o_linklist_is_linked(h2o_linklist_t *node)
+{
+ return node->next != NULL;
+}
+
+inline int h2o_linklist_is_empty(h2o_linklist_t *anchor)
+{
+ return anchor->next == anchor;
+}
+
+inline void h2o_linklist_insert(h2o_linklist_t *pos, h2o_linklist_t *node)
+{
+ assert(!h2o_linklist_is_linked(node));
+
+ node->prev = pos->prev;
+ node->next = pos;
+ node->prev->next = node;
+ node->next->prev = node;
+}
+
+inline void h2o_linklist_insert_list(h2o_linklist_t *pos, h2o_linklist_t *list)
+{
+ if (h2o_linklist_is_empty(list))
+ return;
+ list->next->prev = pos->prev;
+ list->prev->next = pos;
+ pos->prev->next = list->next;
+ pos->prev = list->prev;
+ h2o_linklist_init_anchor(list);
+}
+
+inline void h2o_linklist_unlink(h2o_linklist_t *node)
+{
+ node->next->prev = node->prev;
+ node->prev->next = node->next;
+ node->next = node->prev = NULL;
+}
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/debian/vendor-h2o/include/h2o/memcached.h b/debian/vendor-h2o/include/h2o/memcached.h
new file mode 100644
index 0000000..2bd7da8
--- /dev/null
+++ b/debian/vendor-h2o/include/h2o/memcached.h
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2014,2015 DeNA Co., Ltd., Kazuho Oku
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+#ifndef h2o__memcached_h
+#define h2o__memcached_h
+
+#include <pthread.h>
+#include "h2o/memory.h"
+#include "h2o/multithread.h"
+
+#define H2O_MEMCACHED_ENCODE_KEY 0x1
+#define H2O_MEMCACHED_ENCODE_VALUE 0x2
+
+typedef struct st_h2o_memcached_context_t h2o_memcached_context_t;
+typedef struct st_h2o_memcached_req_t h2o_memcached_req_t;
+typedef void (*h2o_memcached_get_cb)(h2o_iovec_t value, void *cb_data);
+
+h2o_memcached_context_t *h2o_memcached_create_context(const char *host, uint16_t port, int text_protocol, size_t num_threads,
+ const char *prefix);
+
+void h2o_memcached_receiver(h2o_multithread_receiver_t *receiver, h2o_linklist_t *messages);
+
+h2o_memcached_req_t *h2o_memcached_get(h2o_memcached_context_t *ctx, h2o_multithread_receiver_t *receiver, h2o_iovec_t key,
+ h2o_memcached_get_cb cb, void *cb_data, int flags);
+
+void h2o_memcached_cancel_get(h2o_memcached_context_t *ctx, h2o_memcached_req_t *req);
+
+void h2o_memcached_set(h2o_memcached_context_t *ctx, h2o_iovec_t key, h2o_iovec_t value, uint32_t expiration, int flags);
+
+void h2o_memcached_delete(h2o_memcached_context_t *ctx, h2o_iovec_t key, int flags);
+
+#endif
diff --git a/debian/vendor-h2o/include/h2o/memory.h b/debian/vendor-h2o/include/h2o/memory.h
new file mode 100644
index 0000000..10c137c
--- /dev/null
+++ b/debian/vendor-h2o/include/h2o/memory.h
@@ -0,0 +1,437 @@
+/*
+ * Copyright (c) 2014,2015 DeNA Co., Ltd., Kazuho Oku, Justin Zhu
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+#ifndef h2o__memory_h
+#define h2o__memory_h
+
+#ifdef __sun__
+#include <alloca.h>
+#endif
+#include <assert.h>
+#include <stddef.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define H2O_STRUCT_FROM_MEMBER(s, m, p) ((s *)((char *)(p)-offsetof(s, m)))
+
+#if __GNUC__ >= 3
+#define H2O_LIKELY(x) __builtin_expect(!!(x), 1)
+#define H2O_UNLIKELY(x) __builtin_expect(!!(x), 0)
+#else
+#define H2O_LIKELY(x) (x)
+#define H2O_UNLIKELY(x) (x)
+#endif
+
+#ifdef __GNUC__
+#define H2O_GNUC_VERSION ((__GNUC__ << 16) | (__GNUC_MINOR__ << 8) | __GNUC_PATCHLEVEL__)
+#else
+#define H2O_GNUC_VERSION 0
+#endif
+
+#if __STDC_VERSION__ >= 201112L
+#define H2O_NORETURN _Noreturn
+#elif defined(__clang__) || defined(__GNUC__) && H2O_GNUC_VERSION >= 0x20500
+// noreturn was not defined before gcc 2.5
+#define H2O_NORETURN __attribute__((noreturn))
+#else
+#define H2O_NORETURN
+#endif
+
+#if !defined(__clang__) && defined(__GNUC__) && H2O_GNUC_VERSION >= 0x40900
+// returns_nonnull was seemingly not defined before gcc 4.9 (exists in 4.9.1 but not in 4.8.2)
+#define H2O_RETURNS_NONNULL __attribute__((returns_nonnull))
+#else
+#define H2O_RETURNS_NONNULL
+#endif
+
+#define H2O_TO__STR(n) #n
+#define H2O_TO_STR(n) H2O_TO__STR(n)
+
+#define H2O_BUILD_ASSERT(condition) ((void)sizeof(char[2 * !!(!__builtin_constant_p(condition) || (condition)) - 1]))
+
+typedef struct st_h2o_buffer_prototype_t h2o_buffer_prototype_t;
+
+/**
+ * buffer structure compatible with iovec
+ */
+typedef struct st_h2o_iovec_t {
+ char *base;
+ size_t len;
+} h2o_iovec_t;
+
+typedef struct st_h2o_mem_recycle_t {
+ size_t max;
+ size_t cnt;
+ struct st_h2o_mem_recycle_chunk_t *_link;
+} h2o_mem_recycle_t;
+
+struct st_h2o_mem_pool_shared_entry_t {
+ size_t refcnt;
+ void (*dispose)(void *);
+ char bytes[1];
+};
+
+/**
+ * the memory pool
+ */
+typedef struct st_h2o_mem_pool_t {
+ struct st_h2o_mem_pool_chunk_t *chunks;
+ size_t chunk_offset;
+ struct st_h2o_mem_pool_shared_ref_t *shared_refs;
+ struct st_h2o_mem_pool_direct_t *directs;
+} h2o_mem_pool_t;
+
+/**
+ * buffer used to store incoming / outgoing octets
+ */
+typedef struct st_h2o_buffer_t {
+ /**
+ * capacity of the buffer (or minimum initial capacity in case of a prototype (i.e. bytes == NULL))
+ */
+ size_t capacity;
+ /**
+ * amount of the data available
+ */
+ size_t size;
+ /**
+ * pointer to the start of the data (or NULL if is pointing to a prototype)
+ */
+ char *bytes;
+ /**
+ * prototype (or NULL if the instance is part of the prototype (i.e. bytes == NULL))
+ */
+ h2o_buffer_prototype_t *_prototype;
+ /**
+ * file descriptor (if not -1, used to store the buffer)
+ */
+ int _fd;
+ char _buf[1];
+} h2o_buffer_t;
+
+typedef struct st_h2o_buffer_mmap_settings_t {
+ size_t threshold;
+ char fn_template[FILENAME_MAX];
+} h2o_buffer_mmap_settings_t;
+
+struct st_h2o_buffer_prototype_t {
+ h2o_mem_recycle_t allocator;
+ h2o_buffer_t _initial_buf;
+ h2o_buffer_mmap_settings_t *mmap_settings;
+};
+
+#define H2O_VECTOR(type) \
+ struct { \
+ type *entries; \
+ size_t size; \
+ size_t capacity; \
+ }
+
+typedef H2O_VECTOR(void) h2o_vector_t;
+typedef H2O_VECTOR(h2o_iovec_t) h2o_iovec_vector_t;
+
+extern void *(*h2o_mem__set_secure)(void *, int, size_t);
+
+/**
+ * prints an error message and aborts
+ */
+#define h2o_fatal(msg) h2o__fatal(__FILE__ ":" H2O_TO_STR(__LINE__) ":" msg)
+H2O_NORETURN void h2o__fatal(const char *msg);
+
+/**
+ * A version of memcpy that can take a NULL @src to avoid UB
+ */
+static void *h2o_memcpy(void *dst, const void *src, size_t n);
+/**
+ * constructor for h2o_iovec_t
+ */
+static h2o_iovec_t h2o_iovec_init(const void *base, size_t len);
+/**
+ * wrapper of malloc; allocates given size of memory or dies if impossible
+ */
+H2O_RETURNS_NONNULL static void *h2o_mem_alloc(size_t sz);
+/**
+ * warpper of realloc; reallocs the given chunk or dies if impossible
+ */
+static void *h2o_mem_realloc(void *oldp, size_t sz);
+
+/**
+ * allocates memory using the reusing allocator
+ */
+void *h2o_mem_alloc_recycle(h2o_mem_recycle_t *allocator, size_t sz);
+/**
+ * returns the memory to the reusing allocator
+ */
+void h2o_mem_free_recycle(h2o_mem_recycle_t *allocator, void *p);
+
+/**
+ * initializes the memory pool.
+ */
+void h2o_mem_init_pool(h2o_mem_pool_t *pool);
+/**
+ * clears the memory pool.
+ * Applications may dispose the pool after calling the function or reuse it without calling h2o_mem_init_pool.
+ */
+void h2o_mem_clear_pool(h2o_mem_pool_t *pool);
+/**
+ * allocates given size of memory from the memory pool, or dies if impossible
+ */
+void *h2o_mem_alloc_pool(h2o_mem_pool_t *pool, size_t sz);
+/**
+ * allocates a ref-counted chunk of given size from the memory pool, or dies if impossible.
+ * The ref-count of the returned chunk is 1 regardless of whether or not the chunk is linked to a pool.
+ * @param pool pool to which the allocated chunk should be linked (or NULL to allocate an orphan chunk)
+ */
+void *h2o_mem_alloc_shared(h2o_mem_pool_t *pool, size_t sz, void (*dispose)(void *));
+/**
+ * links a ref-counted chunk to a memory pool.
+ * The ref-count of the chunk will be decremented when the pool is cleared.
+ * It is permitted to link a chunk more than once to a single pool.
+ */
+void h2o_mem_link_shared(h2o_mem_pool_t *pool, void *p);
+/**
+ * increments the reference count of a ref-counted chunk.
+ */
+static void h2o_mem_addref_shared(void *p);
+/**
+ * decrements the reference count of a ref-counted chunk.
+ * The chunk gets freed when the ref-count reaches zero.
+ */
+static int h2o_mem_release_shared(void *p);
+/**
+ * initialize the buffer using given prototype.
+ */
+static void h2o_buffer_init(h2o_buffer_t **buffer, h2o_buffer_prototype_t *prototype);
+/**
+ *
+ */
+void h2o_buffer__do_free(h2o_buffer_t *buffer);
+/**
+ * disposes of the buffer
+ */
+static void h2o_buffer_dispose(h2o_buffer_t **buffer);
+/**
+ * allocates a buffer.
+ * @param inbuf - pointer to a pointer pointing to the structure (set *inbuf to NULL to allocate a new buffer)
+ * @param min_guarantee minimum number of bytes to reserve
+ * @return buffer to which the next data should be stored
+ * @note When called against a new buffer, the function returns a buffer twice the size of requested guarantee. The function uses
+ * exponential backoff for already-allocated buffers.
+ */
+h2o_iovec_t h2o_buffer_reserve(h2o_buffer_t **inbuf, size_t min_guarantee);
+/**
+ * throws away given size of the data from the buffer.
+ * @param delta number of octets to be drained from the buffer
+ */
+void h2o_buffer_consume(h2o_buffer_t **inbuf, size_t delta);
+/**
+ * resets the buffer prototype
+ */
+static void h2o_buffer_set_prototype(h2o_buffer_t **buffer, h2o_buffer_prototype_t *prototype);
+/**
+ * registers a buffer to memory pool, so that it would be freed when the pool is flushed. Note that the buffer cannot be resized
+ * after it is linked.
+ */
+static void h2o_buffer_link_to_pool(h2o_buffer_t *buffer, h2o_mem_pool_t *pool);
+void h2o_buffer__dispose_linked(void *p);
+/**
+ * grows the vector so that it could store at least new_capacity elements of given size (or dies if impossible).
+ * @param pool memory pool that the vector is using
+ * @param vector the vector
+ * @param element_size size of the elements stored in the vector
+ * @param new_capacity the capacity of the buffer after the function returns
+ */
+#define h2o_vector_reserve(pool, vector, new_capacity) \
+ h2o_vector__reserve((pool), (h2o_vector_t *)(void *)(vector), sizeof((vector)->entries[0]), (new_capacity))
+static void h2o_vector__reserve(h2o_mem_pool_t *pool, h2o_vector_t *vector, size_t element_size, size_t new_capacity);
+void h2o_vector__expand(h2o_mem_pool_t *pool, h2o_vector_t *vector, size_t element_size, size_t new_capacity);
+/**
+ * erase the entry at given index from the vector
+ */
+#define h2o_vector_erase(vector, index) h2o_vector__erase((h2o_vector_t *)(void *)(vector), sizeof((vector)->entries[0]), (index))
+static void h2o_vector__erase(h2o_vector_t *vector, size_t element_size, size_t index);
+
+/**
+ * tests if target chunk (target_len bytes long) is equal to test chunk (test_len bytes long)
+ */
+static int h2o_memis(const void *target, size_t target_len, const void *test, size_t test_len);
+
+/**
+ * variant of memchr that searches the string from tail
+ */
+static void *h2o_memrchr(const void *s, int c, size_t n);
+
+/**
+ * secure memset
+ */
+static void *h2o_mem_set_secure(void *b, int c, size_t len);
+
+/**
+ * swaps contents of memory
+ */
+void h2o_mem_swap(void *x, void *y, size_t len);
+
+/**
+ * emits hexdump of given buffer to fp
+ */
+void h2o_dump_memory(FILE *fp, const char *buf, size_t len);
+
+/**
+ * appends an element to a NULL-terminated list allocated using malloc
+ */
+void h2o_append_to_null_terminated_list(void ***list, void *element);
+
+/* inline defs */
+
+inline void *h2o_memcpy(void *dst, const void *src, size_t n)
+{
+ if (src != NULL)
+ return memcpy(dst, src, n);
+ else if (n != 0)
+ h2o_fatal("null pointer passed to memcpy");
+ return dst;
+}
+
+inline h2o_iovec_t h2o_iovec_init(const void *base, size_t len)
+{
+ /* intentionally declared to take a "const void*" since it may contain any type of data and since _some_ buffers are constant */
+ h2o_iovec_t buf;
+ buf.base = (char *)base;
+ buf.len = len;
+ return buf;
+}
+
+inline void *h2o_mem_alloc(size_t sz)
+{
+ void *p = malloc(sz);
+ if (p == NULL)
+ h2o_fatal("no memory");
+ return p;
+}
+
+inline void *h2o_mem_realloc(void *oldp, size_t sz)
+{
+ void *newp = realloc(oldp, sz);
+ if (newp == NULL) {
+ h2o_fatal("no memory");
+ return oldp;
+ }
+ return newp;
+}
+
+inline void h2o_mem_addref_shared(void *p)
+{
+ struct st_h2o_mem_pool_shared_entry_t *entry = H2O_STRUCT_FROM_MEMBER(struct st_h2o_mem_pool_shared_entry_t, bytes, p);
+ assert(entry->refcnt != 0);
+ ++entry->refcnt;
+}
+
+inline int h2o_mem_release_shared(void *p)
+{
+ struct st_h2o_mem_pool_shared_entry_t *entry = H2O_STRUCT_FROM_MEMBER(struct st_h2o_mem_pool_shared_entry_t, bytes, p);
+ if (--entry->refcnt == 0) {
+ if (entry->dispose != NULL)
+ entry->dispose(entry->bytes);
+ free(entry);
+ return 1;
+ }
+ return 0;
+}
+
+inline void h2o_buffer_init(h2o_buffer_t **buffer, h2o_buffer_prototype_t *prototype)
+{
+ *buffer = &prototype->_initial_buf;
+}
+
+inline void h2o_buffer_dispose(h2o_buffer_t **_buffer)
+{
+ h2o_buffer_t *buffer = *_buffer;
+ *_buffer = NULL;
+ if (buffer->bytes != NULL)
+ h2o_buffer__do_free(buffer);
+}
+
+inline void h2o_buffer_set_prototype(h2o_buffer_t **buffer, h2o_buffer_prototype_t *prototype)
+{
+ if ((*buffer)->_prototype != NULL)
+ (*buffer)->_prototype = prototype;
+ else
+ *buffer = &prototype->_initial_buf;
+}
+
+inline void h2o_buffer_link_to_pool(h2o_buffer_t *buffer, h2o_mem_pool_t *pool)
+{
+ h2o_buffer_t **slot = (h2o_buffer_t **)h2o_mem_alloc_shared(pool, sizeof(*slot), h2o_buffer__dispose_linked);
+ *slot = buffer;
+}
+
+inline void h2o_vector__reserve(h2o_mem_pool_t *pool, h2o_vector_t *vector, size_t element_size, size_t new_capacity)
+{
+ if (vector->capacity < new_capacity) {
+ h2o_vector__expand(pool, vector, element_size, new_capacity);
+ }
+}
+
+inline void h2o_vector__erase(h2o_vector_t *vector, size_t element_size, size_t index)
+{
+ char *entries = (char *)vector->entries;
+ memmove(entries + element_size * index, entries + element_size * (index + 1), vector->size - index - 1);
+ --vector->size;
+}
+
+inline int h2o_memis(const void *_target, size_t target_len, const void *_test, size_t test_len)
+{
+ const char *target = (const char *)_target, *test = (const char *)_test;
+ if (target_len != test_len)
+ return 0;
+ if (target_len == 0)
+ return 1;
+ if (target[0] != test[0])
+ return 0;
+ return memcmp(target + 1, test + 1, test_len - 1) == 0;
+}
+
+inline void *h2o_memrchr(const void *s, int c, size_t n)
+{
+ if (n != 0) {
+ const char *p = (const char *)s + n;
+ do {
+ if (*--p == c)
+ return (void *)p;
+ } while (p != s);
+ }
+ return NULL;
+}
+
+inline void *h2o_mem_set_secure(void *b, int c, size_t len)
+{
+ return h2o_mem__set_secure(b, c, len);
+}
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/debian/vendor-h2o/include/h2o/mruby_.h b/debian/vendor-h2o/include/h2o/mruby_.h
new file mode 100644
index 0000000..908d34f
--- /dev/null
+++ b/debian/vendor-h2o/include/h2o/mruby_.h
@@ -0,0 +1,178 @@
+/*
+ * Copyright (c) 2014-2016 DeNA Co., Ltd., Kazuho Oku, Ryosuke Matsumoto
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+#ifndef H20_MRUBY_H
+#define H20_MRUBY_H
+
+#include "h2o.h"
+#include <mruby.h>
+#include <mruby/data.h>
+#include <mruby/proc.h>
+#include <mruby/compile.h>
+
+#define H2O_MRUBY_MODULE_NAME "h2o_mruby"
+
+enum {
+ H2O_MRUBY_LIT_REQUEST_METHOD = H2O_MAX_TOKENS,
+ H2O_MRUBY_LIT_SCRIPT_NAME,
+ H2O_MRUBY_LIT_PATH_INFO,
+ H2O_MRUBY_LIT_QUERY_STRING,
+ H2O_MRUBY_LIT_SERVER_NAME,
+ H2O_MRUBY_LIT_SERVER_ADDR,
+ H2O_MRUBY_LIT_SERVER_PORT,
+ H2O_MRUBY_LIT_SERVER_PROTOCOL,
+ H2O_MRUBY_LIT_CONTENT_LENGTH,
+ H2O_MRUBY_LIT_REMOTE_ADDR,
+ H2O_MRUBY_LIT_REMOTE_PORT,
+ H2O_MRUBY_LIT_REMOTE_USER,
+ H2O_MRUBY_LIT_RACK_URL_SCHEME,
+ H2O_MRUBY_LIT_RACK_MULTITHREAD,
+ H2O_MRUBY_LIT_RACK_MULTIPROCESS,
+ H2O_MRUBY_LIT_RACK_RUN_ONCE,
+ H2O_MRUBY_LIT_RACK_HIJACK_,
+ H2O_MRUBY_LIT_RACK_INPUT,
+ H2O_MRUBY_LIT_RACK_ERRORS,
+ H2O_MRUBY_LIT_SERVER_SOFTWARE,
+ H2O_MRUBY_LIT_SERVER_SOFTWARE_VALUE,
+ H2O_MRUBY_LIT_SEPARATOR_COMMA,
+ H2O_MRUBY_LIT_SEPARATOR_SEMICOLON,
+ H2O_MRUBY_PROC_EACH_TO_ARRAY,
+ H2O_MRUBY_PROC_APP_TO_FIBER,
+
+ /* used by chunked.c */
+ H2O_MRUBY_CHUNKED_PROC_EACH_TO_FIBER,
+
+ /* used by http_request.c */
+ H2O_MRUBY_HTTP_REQUEST_CLASS,
+ H2O_MRUBY_HTTP_INPUT_STREAM_CLASS,
+ H2O_MRUBY_HTTP_EMPTY_INPUT_STREAM_CLASS,
+
+ H2O_MRUBY_NUM_CONSTANTS
+};
+
+typedef struct st_h2o_mruby_config_vars_t {
+ h2o_iovec_t source;
+ char *path;
+ int lineno;
+} h2o_mruby_config_vars_t;
+
+typedef struct st_h2o_mruby_handler_t {
+ h2o_handler_t super;
+ h2o_mruby_config_vars_t config;
+} h2o_mruby_handler_t;
+
+typedef struct st_h2o_mruby_shared_context_t {
+ mrb_state *mrb;
+ mrb_value constants;
+ struct {
+ mrb_sym sym_call;
+ mrb_sym sym_close;
+ mrb_sym sym_method;
+ mrb_sym sym_headers;
+ mrb_sym sym_body;
+ mrb_sym sym_async;
+ } symbols;
+} h2o_mruby_shared_context_t;
+
+typedef struct st_h2o_mruby_context_t {
+ h2o_mruby_handler_t *handler;
+ mrb_value proc;
+ h2o_mruby_shared_context_t *shared;
+} h2o_mruby_context_t;
+
+typedef struct st_h2o_mruby_chunked_t h2o_mruby_chunked_t;
+typedef struct st_h2o_mruby_http_request_context_t h2o_mruby_http_request_context_t;
+
+typedef struct st_h2o_mruby_generator_t {
+ h2o_generator_t super;
+ h2o_req_t *req; /* becomes NULL once the underlying connection gets terminated */
+ h2o_mruby_context_t *ctx;
+ mrb_value rack_input;
+ h2o_mruby_chunked_t *chunked;
+} h2o_mruby_generator_t;
+
+#define H2O_MRUBY_CALLBACK_ID_EXCEPTION_RAISED -1 /* used to notify exception, does not execution to mruby code */
+#define H2O_MRUBY_CALLBACK_ID_SEND_CHUNKED_EOS -2
+#define H2O_MRUBY_CALLBACK_ID_HTTP_JOIN_RESPONSE -3
+#define H2O_MRUBY_CALLBACK_ID_HTTP_FETCH_CHUNK -4
+
+enum { H2O_MRUBY_CALLBACK_NEXT_ACTION_STOP, H2O_MRUBY_CALLBACK_NEXT_ACTION_IMMEDIATE, H2O_MRUBY_CALLBACK_NEXT_ACTION_ASYNC };
+
+#define h2o_mruby_assert(mrb) \
+ if (mrb->exc != NULL) \
+ h2o_mruby__assert_failed(mrb, __FILE__, __LINE__)
+
+/* source files using this macro should include mruby/throw.h */
+#define H2O_MRUBY_EXEC_GUARD(block) \
+ do { \
+ struct mrb_jmpbuf *prev_jmp = mrb->jmp; \
+ struct mrb_jmpbuf c_jmp; \
+ MRB_TRY(&c_jmp) \
+ { \
+ mrb->jmp = &c_jmp; \
+ do { \
+ block \
+ } while (0); \
+ mrb->jmp = prev_jmp; \
+ } \
+ MRB_CATCH(&c_jmp) \
+ { \
+ mrb->jmp = prev_jmp; \
+ } \
+ MRB_END_EXC(&c_jmp); \
+ } while (0)
+
+/* handler/mruby.c */
+extern __thread h2o_mruby_generator_t *h2o_mruby_current_generator;
+void h2o_mruby__assert_failed(mrb_state *mrb, const char *file, int line);
+mrb_value h2o_mruby_to_str(mrb_state *mrb, mrb_value v);
+mrb_value h2o_mruby_eval_expr(mrb_state *mrb, const char *expr);
+void h2o_mruby_define_callback(mrb_state *mrb, const char *name, int id);
+mrb_value h2o_mruby_create_data_instance(mrb_state *mrb, mrb_value class_obj, void *ptr, const mrb_data_type *type);
+void h2o_mruby_setup_globals(mrb_state *mrb);
+mrb_value h2o_mruby_compile_code(mrb_state *mrb, h2o_mruby_config_vars_t *config, char *errbuf);
+h2o_mruby_handler_t *h2o_mruby_register(h2o_pathconf_t *pathconf, h2o_mruby_config_vars_t *config);
+void h2o_mruby_run_fiber(h2o_mruby_generator_t *generator, mrb_value receiver, mrb_value input, int *is_delegate);
+mrb_value h2o_mruby_each_to_array(h2o_mruby_context_t *handler_ctx, mrb_value src);
+int h2o_mruby_iterate_headers(h2o_mruby_context_t *handler_ctx, mrb_value headers,
+ int (*cb)(h2o_mruby_context_t *, h2o_iovec_t, h2o_iovec_t, void *), void *cb_data);
+
+/* handler/mruby/chunked.c */
+void h2o_mruby_send_chunked_init_context(h2o_mruby_shared_context_t *ctx);
+void h2o_mruby_send_chunked_close(h2o_mruby_generator_t *generator);
+mrb_value h2o_mruby_send_chunked_init(h2o_mruby_generator_t *generator, mrb_value body);
+void h2o_mruby_send_chunked_dispose(h2o_mruby_generator_t *generator);
+mrb_value h2o_mruby_send_chunked_eos_callback(h2o_mruby_generator_t *generator, mrb_value receiver, mrb_value input,
+ int *next_action);
+
+/* handler/mruby/http_request.c */
+void h2o_mruby_http_request_init_context(h2o_mruby_shared_context_t *ctx);
+mrb_value h2o_mruby_http_join_response_callback(h2o_mruby_generator_t *generator, mrb_value receiver, mrb_value args,
+ int *next_action);
+mrb_value h2o_mruby_http_fetch_chunk_callback(h2o_mruby_generator_t *generator, mrb_value receiver, mrb_value input,
+ int *next_action);
+h2o_mruby_http_request_context_t *h2o_mruby_http_set_shortcut(mrb_state *mrb, mrb_value obj, void (*cb)(h2o_mruby_generator_t *));
+h2o_buffer_t **h2o_mruby_http_peek_content(h2o_mruby_http_request_context_t *ctx, int *is_final);
+
+/* handler/configurator/mruby.c */
+void h2o_mruby_register_configurator(h2o_globalconf_t *conf);
+
+#endif
diff --git a/debian/vendor-h2o/include/h2o/multithread.h b/debian/vendor-h2o/include/h2o/multithread.h
new file mode 100644
index 0000000..d089379
--- /dev/null
+++ b/debian/vendor-h2o/include/h2o/multithread.h
@@ -0,0 +1,107 @@
+/*
+ * Copyright (c) 2015 DeNA Co., Ltd., Kazuho Oku, Tatsuhiko Kubo
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+#ifndef h2o__multithread_h
+#define h2o__multithread_h
+
+#include <pthread.h>
+#include "h2o/linklist.h"
+#include "h2o/socket.h"
+
+typedef struct st_h2o_multithread_receiver_t h2o_multithread_receiver_t;
+typedef struct st_h2o_multithread_queue_t h2o_multithread_queue_t;
+typedef struct st_h2o_multithread_request_t h2o_multithread_request_t;
+
+typedef void (*h2o_multithread_receiver_cb)(h2o_multithread_receiver_t *receiver, h2o_linklist_t *messages);
+typedef void (*h2o_multithread_response_cb)(h2o_multithread_request_t *req);
+
+struct st_h2o_multithread_receiver_t {
+ h2o_multithread_queue_t *queue;
+ h2o_linklist_t _link;
+ h2o_linklist_t _messages;
+ h2o_multithread_receiver_cb cb;
+};
+
+typedef struct st_h2o_multithread_message_t {
+ h2o_linklist_t link;
+} h2o_multithread_message_t;
+
+struct st_h2o_multithread_request_t {
+ h2o_multithread_message_t super;
+ h2o_multithread_receiver_t *source;
+ h2o_multithread_response_cb cb;
+};
+
+typedef struct st_h2o_sem_t {
+ pthread_mutex_t _mutex;
+ pthread_cond_t _cond;
+ ssize_t _cur;
+ ssize_t _capacity;
+} h2o_sem_t;
+
+typedef struct st_h2o_barrier_t {
+ pthread_mutex_t _mutex;
+ pthread_cond_t _cond;
+ size_t _count;
+} h2o_barrier_t;
+
+/**
+ * creates a queue that is used for inter-thread communication
+ */
+h2o_multithread_queue_t *h2o_multithread_create_queue(h2o_loop_t *loop);
+/**
+ * destroys the queue
+ */
+void h2o_multithread_destroy_queue(h2o_multithread_queue_t *queue);
+/**
+ * registers a receiver for specific type of message
+ */
+void h2o_multithread_register_receiver(h2o_multithread_queue_t *queue, h2o_multithread_receiver_t *receiver,
+ h2o_multithread_receiver_cb cb);
+/**
+ * unregisters a receiver
+ */
+void h2o_multithread_unregister_receiver(h2o_multithread_queue_t *queue, h2o_multithread_receiver_t *receiver);
+/**
+ * sends a message (or set message to NULL to just wake up the receiving thread)
+ */
+void h2o_multithread_send_message(h2o_multithread_receiver_t *receiver, h2o_multithread_message_t *message);
+/**
+ * sends a request
+ */
+void h2o_multithread_send_request(h2o_multithread_receiver_t *receiver, h2o_multithread_request_t *req);
+/**
+ * create a thread
+ */
+void h2o_multithread_create_thread(pthread_t *tid, const pthread_attr_t *attr, void *(*func)(void *), void *arg);
+
+void h2o_sem_init(h2o_sem_t *sem, ssize_t capacity);
+void h2o_sem_destroy(h2o_sem_t *sem);
+void h2o_sem_wait(h2o_sem_t *sem);
+void h2o_sem_post(h2o_sem_t *sem);
+void h2o_sem_set_capacity(h2o_sem_t *sem, ssize_t new_capacity);
+
+#define H2O_BARRIER_INITIALIZER(count_) {PTHREAD_MUTEX_INITIALIZER, PTHREAD_COND_INITIALIZER, count_}
+void h2o_barrier_init(h2o_barrier_t *barrier, size_t count);
+int h2o_barrier_wait(h2o_barrier_t *barrier);
+int h2o_barrier_done(h2o_barrier_t *barrier);
+
+#endif
diff --git a/debian/vendor-h2o/include/h2o/openssl_backport.h b/debian/vendor-h2o/include/h2o/openssl_backport.h
new file mode 100644
index 0000000..72cc43c
--- /dev/null
+++ b/debian/vendor-h2o/include/h2o/openssl_backport.h
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 2016 DeNA Co., Ltd., Kazuho Oku
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+#ifndef h2o__openssl_backport_h
+#define h2o__openssl_backport_h
+
+#include <stdlib.h>
+
+/* backports for OpenSSL 1.0.2 */
+#if OPENSSL_VERSION_NUMBER < 0x10100000L || (defined(LIBRESSL_VERSION_NUMBER) && LIBRESSL_VERSION_NUMBER < 0x2070000fL)
+
+#define BIO_get_data(bio) ((bio)->ptr)
+#define BIO_set_data(bio, p) ((bio)->ptr = (p))
+#define BIO_get_init(bio) ((bio)->init)
+#define BIO_set_init(bio, i) ((bio)->init = (i))
+#define BIO_get_shutdown(bio) ((bio)->shutdown)
+#define BIO_set_shutdown(bio, shut) ((bio)->shutdown = (shut))
+
+static inline BIO_METHOD *BIO_meth_new(int type, const char *name)
+{
+ BIO_METHOD *bm = (BIO_METHOD *)malloc(sizeof(*bm));
+ if (bm != NULL) {
+ memset(bm, 0, sizeof(*bm));
+ bm->type = type;
+ bm->name = name;
+ }
+ return bm;
+}
+
+#define BIO_meth_set_write(bm, cb) ((bm)->bwrite = cb)
+#define BIO_meth_set_read(bm, cb) ((bm)->bread = cb)
+#define BIO_meth_set_puts(bm, cb) ((bm)->bputs = cb)
+#define BIO_meth_set_ctrl(bm, cb) ((bm)->ctrl = cb)
+
+#define SSL_CTX_up_ref(ctx) CRYPTO_add(&(ctx)->references, 1, CRYPTO_LOCK_SSL_CTX)
+
+#define X509_STORE_up_ref(store) CRYPTO_add(&(store)->references, 1, CRYPTO_LOCK_X509_STORE)
+
+#endif
+
+/* backports for OpenSSL 1.0.1 and LibreSSL */
+#if OPENSSL_VERSION_NUMBER < 0x10002000L || (defined(LIBRESSL_VERSION_NUMBER) && LIBRESSL_VERSION_NUMBER < 0x2070000fL)
+
+#define SSL_is_server(ssl) ((ssl)->server)
+
+#endif
+
+#endif
diff --git a/debian/vendor-h2o/include/h2o/rand.h b/debian/vendor-h2o/include/h2o/rand.h
new file mode 100644
index 0000000..76721d2
--- /dev/null
+++ b/debian/vendor-h2o/include/h2o/rand.h
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2016 David Carlier
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+#ifndef h2o__rand_h
+#define h2o__rand_h
+
+#include <stdlib.h>
+#include <unistd.h>
+
+#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
+#define h2o_srand()
+#define h2o_rand() arc4random()
+#else
+#define h2o_srand() srand(time(NULL) ^ getpid())
+#define h2o_rand() rand()
+#endif
+#endif
diff --git a/debian/vendor-h2o/include/h2o/serverutil.h b/debian/vendor-h2o/include/h2o/serverutil.h
new file mode 100644
index 0000000..7698cdc
--- /dev/null
+++ b/debian/vendor-h2o/include/h2o/serverutil.h
@@ -0,0 +1,81 @@
+/*
+ * Copyright (c) 2014 DeNA Co., Ltd.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+#ifndef h2o__server_starter_h
+#define h2o__server_starter_h
+
+#include <stddef.h>
+
+/* taken from sysexits.h */
+#ifndef EX_SOFTWARE
+#define EX_SOFTWARE 70
+#endif
+#ifndef EX_OSERR
+#define EX_OSERR 71
+#endif
+#ifndef EX_TEMPFAIL
+#define EX_TEMPFAIL 75
+#endif
+#ifndef EX_CONFIG
+#define EX_CONFIG 78
+#endif
+
+/**
+ * equivalent of signal(3)
+ */
+void h2o_set_signal_handler(int signo, void (*cb)(int signo));
+
+/**
+ * equiv. to setuidgid of djb
+ */
+int h2o_setuidgid(const char *user);
+
+/**
+ * return a list of fds passed in from Server::Starter, or 0 if Server::Starter was not used. -1 on error
+ */
+size_t h2o_server_starter_get_fds(int **_fds);
+
+/**
+ * spawns a command with given arguments, while mapping the designated file descriptors.
+ * @param cmd file being executed
+ * @param argv argv passed to the executable
+ * @param mapped_fds if non-NULL, must point to an array contain containing a list of pair of file descriptors, terminated with -1.
+ * Every pair of the mapping will be duplicated by calling `dup2` before execvp is being called if the second value of the
+ * pair is not -1. If the second value is -1, then `close` is called with the first value as the argument.
+ * @return pid of the process being spawned if successful, or -1 if otherwise
+ */
+pid_t h2o_spawnp(const char *cmd, char *const *argv, const int *mapped_fds, int clocexec_mutex_is_locked);
+
+/**
+ * executes a command and returns its output
+ * @param cmd
+ * @param argv
+ * @param resp the output, only available if the function returns zero
+ * @param child_status result of waitpid(child_pid), only available if the function returns zero
+ */
+int h2o_read_command(const char *cmd, char **argv, h2o_buffer_t **resp, int *child_status);
+
+/**
+ * Gets the number of processor cores
+ */
+size_t h2o_numproc(void);
+
+#endif
diff --git a/debian/vendor-h2o/include/h2o/socket.h b/debian/vendor-h2o/include/h2o/socket.h
new file mode 100644
index 0000000..9727e34
--- /dev/null
+++ b/debian/vendor-h2o/include/h2o/socket.h
@@ -0,0 +1,403 @@
+/*
+ * Copyright (c) 2014-2016 DeNA Co., Ltd., Kazuho Oku, Fastly, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+#ifndef h2o__socket_h
+#define h2o__socket_h
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <stdint.h>
+#include <sys/socket.h>
+#include <openssl/ssl.h>
+#include "h2o/cache.h"
+#include "h2o/memory.h"
+#include "h2o/openssl_backport.h"
+#include "h2o/string_.h"
+
+#ifndef H2O_USE_LIBUV
+#if H2O_USE_SELECT || H2O_USE_EPOLL || H2O_USE_KQUEUE
+#define H2O_USE_LIBUV 0
+#else
+#define H2O_USE_LIBUV 1
+#endif
+#endif
+
+#if OPENSSL_VERSION_NUMBER >= 0x10002000L
+#define H2O_USE_ALPN 1
+#define H2O_USE_NPN 1
+#elif OPENSSL_VERSION_NUMBER >= 0x10001000L
+#define H2O_USE_ALPN 0
+#define H2O_USE_NPN 1
+#else
+#define H2O_USE_ALPN 0
+#define H2O_USE_NPN 0
+#endif
+
+typedef struct st_h2o_sliding_counter_t {
+ uint64_t average;
+ struct {
+ uint64_t sum;
+ uint64_t slots[8];
+ size_t index;
+ } prev;
+ struct {
+ uint64_t start_at;
+ } cur;
+} h2o_sliding_counter_t;
+
+static int h2o_sliding_counter_is_running(h2o_sliding_counter_t *counter);
+static void h2o_sliding_counter_start(h2o_sliding_counter_t *counter, uint64_t now);
+void h2o_sliding_counter_stop(h2o_sliding_counter_t *counter, uint64_t now);
+
+#define H2O_SOCKET_INITIAL_INPUT_BUFFER_SIZE 4096
+
+typedef struct st_h2o_socket_t h2o_socket_t;
+
+typedef void (*h2o_socket_cb)(h2o_socket_t *sock, const char *err);
+
+#if H2O_USE_LIBUV
+#include "socket/uv-binding.h"
+#else
+#include "socket/evloop.h"
+#endif
+
+struct st_h2o_socket_peername_t {
+ socklen_t len;
+ struct sockaddr addr;
+};
+
+enum {
+ H2O_SOCKET_LATENCY_OPTIMIZATION_STATE_TBD = 0,
+ H2O_SOCKET_LATENCY_OPTIMIZATION_STATE_NEEDS_UPDATE,
+ H2O_SOCKET_LATENCY_OPTIMIZATION_STATE_DISABLED,
+ H2O_SOCKET_LATENCY_OPTIMIZATION_STATE_DETERMINED
+};
+
+/**
+ * abstraction layer for sockets (SSL vs. TCP)
+ */
+struct st_h2o_socket_t {
+ void *data;
+ struct st_h2o_socket_ssl_t *ssl;
+ h2o_buffer_t *input;
+ /**
+ * total bytes read (above the TLS layer)
+ */
+ size_t bytes_read;
+ /**
+ * total bytes written (above the TLS layer)
+ */
+ size_t bytes_written;
+ struct {
+ void (*cb)(void *data);
+ void *data;
+ } on_close;
+ struct {
+ h2o_socket_cb read;
+ h2o_socket_cb write;
+ } _cb;
+ struct st_h2o_socket_peername_t *_peername;
+ struct {
+ uint8_t state; /* one of H2O_SOCKET_LATENCY_STATE_* */
+ uint8_t notsent_is_minimized : 1;
+ uint16_t suggested_tls_payload_size;
+ size_t suggested_write_size; /* SIZE_MAX if no need to optimize for latency */
+ } _latency_optimization;
+};
+
+typedef struct st_h2o_socket_export_t {
+ int fd;
+ struct st_h2o_socket_ssl_t *ssl;
+ h2o_buffer_t *input;
+} h2o_socket_export_t;
+
+/**
+ * sets the conditions to enable the optimization
+ */
+typedef struct st_h2o_socket_latency_optimization_conditions_t {
+ /**
+ * in milliseconds
+ */
+ unsigned min_rtt;
+ /**
+ * percent ratio
+ */
+ unsigned max_additional_delay;
+ /**
+ * in number of octets
+ */
+ unsigned max_cwnd;
+} h2o_socket_latency_optimization_conditions_t;
+
+typedef void (*h2o_socket_ssl_resumption_get_async_cb)(h2o_socket_t *sock, h2o_iovec_t session_id);
+typedef void (*h2o_socket_ssl_resumption_new_cb)(h2o_iovec_t session_id, h2o_iovec_t session_data);
+typedef void (*h2o_socket_ssl_resumption_remove_cb)(h2o_iovec_t session_id);
+
+extern h2o_buffer_mmap_settings_t h2o_socket_buffer_mmap_settings;
+extern __thread h2o_buffer_prototype_t h2o_socket_buffer_prototype;
+
+extern const char *h2o_socket_error_out_of_memory;
+extern const char *h2o_socket_error_io;
+extern const char *h2o_socket_error_closed;
+extern const char *h2o_socket_error_conn_fail;
+extern const char *h2o_socket_error_ssl_no_cert;
+extern const char *h2o_socket_error_ssl_cert_invalid;
+extern const char *h2o_socket_error_ssl_cert_name_mismatch;
+extern const char *h2o_socket_error_ssl_decode;
+
+/**
+ * returns the loop
+ */
+h2o_loop_t *h2o_socket_get_loop(h2o_socket_t *sock);
+/**
+ * detaches a socket from loop.
+ */
+int h2o_socket_export(h2o_socket_t *sock, h2o_socket_export_t *info);
+/**
+ * attaches a socket onto a loop.
+ */
+h2o_socket_t *h2o_socket_import(h2o_loop_t *loop, h2o_socket_export_t *info);
+/**
+ * destroys an exported socket info.
+ */
+void h2o_socket_dispose_export(h2o_socket_export_t *info);
+/**
+ * closes the socket
+ */
+void h2o_socket_close(h2o_socket_t *sock);
+/**
+ * Schedules a callback to be notify we the socket can be written to
+ */
+void h2o_socket_notify_write(h2o_socket_t *sock, h2o_socket_cb cb);
+/**
+ * Obtain the underlying fd of a sock struct
+ */
+int h2o_socket_get_fd(h2o_socket_t *sock);
+/**
+ * Set/Unset the H2O_SOCKET_FLAG_DONT_READ flag.
+ * Setting it allows to be simply notified rather than having the data
+ * automatically be read.
+ */
+void h2o_socket_dont_read(h2o_socket_t *sock, int dont_read);
+/**
+ * connects to peer
+ */
+h2o_socket_t *h2o_socket_connect(h2o_loop_t *loop, struct sockaddr *addr, socklen_t addrlen, h2o_socket_cb cb);
+/**
+ * prepares for latency-optimized write and returns the number of octets that should be written, or SIZE_MAX if failed to prepare
+ */
+static size_t h2o_socket_prepare_for_latency_optimized_write(h2o_socket_t *sock,
+ const h2o_socket_latency_optimization_conditions_t *conditions);
+size_t h2o_socket_do_prepare_for_latency_optimized_write(h2o_socket_t *sock,
+ const h2o_socket_latency_optimization_conditions_t *conditions);
+/**
+ * writes given data to socket
+ * @param sock the socket
+ * @param bufs an array of buffers
+ * @param bufcnt length of the buffer array
+ * @param cb callback to be called when write is complete
+ */
+void h2o_socket_write(h2o_socket_t *sock, h2o_iovec_t *bufs, size_t bufcnt, h2o_socket_cb cb);
+/**
+ * starts polling on the socket (for read) and calls given callback when data arrives
+ * @param sock the socket
+ * @param cb callback to be called when data arrives
+ * @note callback is called when any data arrives at the TCP level so that the
+ * applications can update their timeout counters. In other words, there is no
+ * guarantee that _new_ data is available when the callback gets called (e.g.
+ * in cases like receiving a partial SSL record or a corrupt TCP packet).
+ */
+void h2o_socket_read_start(h2o_socket_t *sock, h2o_socket_cb cb);
+/**
+ * stops polling on the socket (for read)
+ * @param sock the socket
+ */
+void h2o_socket_read_stop(h2o_socket_t *sock);
+/**
+ * returns a boolean value indicating whether if there is a write is under operation
+ */
+static int h2o_socket_is_writing(h2o_socket_t *sock);
+/**
+ * returns a boolean value indicating whether if the socket is being polled for read
+ */
+static int h2o_socket_is_reading(h2o_socket_t *sock);
+/**
+ * returns the length of the local address obtained (or 0 if failed)
+ */
+socklen_t h2o_socket_getsockname(h2o_socket_t *sock, struct sockaddr *sa);
+/**
+ * returns the length of the remote address obtained (or 0 if failed)
+ */
+socklen_t h2o_socket_getpeername(h2o_socket_t *sock, struct sockaddr *sa);
+/**
+ * sets the remote address (used for overriding the value)
+ */
+void h2o_socket_setpeername(h2o_socket_t *sock, struct sockaddr *sa, socklen_t len);
+/**
+ *
+ */
+const char *h2o_socket_get_ssl_protocol_version(h2o_socket_t *sock);
+int h2o_socket_get_ssl_session_reused(h2o_socket_t *sock);
+const char *h2o_socket_get_ssl_cipher(h2o_socket_t *sock);
+int h2o_socket_get_ssl_cipher_bits(h2o_socket_t *sock);
+h2o_iovec_t h2o_socket_get_ssl_session_id(h2o_socket_t *sock);
+const char *h2o_socket_get_ssl_server_name(const h2o_socket_t *sock);
+static h2o_iovec_t h2o_socket_log_ssl_protocol_version(h2o_socket_t *sock, h2o_mem_pool_t *pool);
+static h2o_iovec_t h2o_socket_log_ssl_session_reused(h2o_socket_t *sock, h2o_mem_pool_t *pool);
+static h2o_iovec_t h2o_socket_log_ssl_cipher(h2o_socket_t *sock, h2o_mem_pool_t *pool);
+h2o_iovec_t h2o_socket_log_ssl_cipher_bits(h2o_socket_t *sock, h2o_mem_pool_t *pool);
+h2o_iovec_t h2o_socket_log_ssl_session_id(h2o_socket_t *sock, h2o_mem_pool_t *pool);
+
+/**
+ * compares socket addresses
+ */
+int h2o_socket_compare_address(struct sockaddr *x, struct sockaddr *y);
+/**
+ * getnameinfo (buf should be NI_MAXHOST in length), returns SIZE_MAX if failed
+ */
+size_t h2o_socket_getnumerichost(struct sockaddr *sa, socklen_t salen, char *buf);
+/**
+ * returns the port number, or -1 if failed
+ */
+int32_t h2o_socket_getport(struct sockaddr *sa);
+/**
+ * performs SSL handshake on a socket
+ * @param sock the socket
+ * @param ssl_ctx SSL context
+ * @param handshake_cb callback to be called when handshake is complete
+ */
+void h2o_socket_ssl_handshake(h2o_socket_t *sock, SSL_CTX *ssl_ctx, const char *server_name, h2o_socket_cb handshake_cb);
+/**
+ * resumes SSL handshake with given session data
+ * @param sock the socket
+ * @param session_data session data (or {NULL,0} if not available)
+ */
+void h2o_socket_ssl_resume_server_handshake(h2o_socket_t *sock, h2o_iovec_t session_data);
+/**
+ * registers callbacks to be called for handling session data
+ */
+void h2o_socket_ssl_async_resumption_init(h2o_socket_ssl_resumption_get_async_cb get_cb, h2o_socket_ssl_resumption_new_cb new_cb);
+/**
+ * setups the SSL context to use the async resumption
+ */
+void h2o_socket_ssl_async_resumption_setup_ctx(SSL_CTX *ctx);
+/**
+ * returns the name of the protocol selected using either NPN or ALPN (ALPN has the precedence).
+ * @param sock the socket
+ */
+h2o_iovec_t h2o_socket_ssl_get_selected_protocol(h2o_socket_t *sock);
+/**
+ *
+ */
+struct st_ptls_context_t *h2o_socket_ssl_get_picotls_context(SSL_CTX *ossl);
+/**
+ * associates a picotls context to SSL_CTX
+ */
+void h2o_socket_ssl_set_picotls_context(SSL_CTX *ossl, struct st_ptls_context_t *ptls);
+/**
+ *
+ */
+h2o_cache_t *h2o_socket_ssl_get_session_cache(SSL_CTX *ctx);
+/**
+ *
+ */
+void h2o_socket_ssl_set_session_cache(SSL_CTX *ctx, h2o_cache_t *cache);
+/**
+ *
+ */
+void h2o_socket_ssl_destroy_session_cache_entry(h2o_iovec_t value);
+/**
+ * registers the protocol list to be used for ALPN
+ */
+void h2o_ssl_register_alpn_protocols(SSL_CTX *ctx, const h2o_iovec_t *protocols);
+/**
+ * registers the protocol list to be used for NPN
+ */
+void h2o_ssl_register_npn_protocols(SSL_CTX *ctx, const char *protocols);
+
+void h2o_socket__write_pending(h2o_socket_t *sock);
+void h2o_socket__write_on_complete(h2o_socket_t *sock, int status);
+
+/* inline defs */
+
+inline int h2o_socket_is_writing(h2o_socket_t *sock)
+{
+ return sock->_cb.write != NULL;
+}
+
+inline int h2o_socket_is_reading(h2o_socket_t *sock)
+{
+ return sock->_cb.read != NULL;
+}
+
+inline size_t h2o_socket_prepare_for_latency_optimized_write(h2o_socket_t *sock,
+ const h2o_socket_latency_optimization_conditions_t *conditions)
+{
+ switch (sock->_latency_optimization.state) {
+ case H2O_SOCKET_LATENCY_OPTIMIZATION_STATE_TBD:
+ case H2O_SOCKET_LATENCY_OPTIMIZATION_STATE_NEEDS_UPDATE:
+ return h2o_socket_do_prepare_for_latency_optimized_write(sock, conditions);
+ default:
+ return sock->_latency_optimization.suggested_write_size;
+ }
+}
+
+inline h2o_iovec_t h2o_socket_log_ssl_protocol_version(h2o_socket_t *sock, h2o_mem_pool_t *pool)
+{
+ const char *s = h2o_socket_get_ssl_protocol_version(sock);
+ return s != NULL ? h2o_iovec_init(s, strlen(s)) : h2o_iovec_init(NULL, 0);
+}
+
+inline h2o_iovec_t h2o_socket_log_ssl_session_reused(h2o_socket_t *sock, h2o_mem_pool_t *pool)
+{
+ switch (h2o_socket_get_ssl_session_reused(sock)) {
+ case 0:
+ return h2o_iovec_init(H2O_STRLIT("0"));
+ case 1:
+ return h2o_iovec_init(H2O_STRLIT("1"));
+ default:
+ return h2o_iovec_init(NULL, 0);
+ }
+}
+
+inline h2o_iovec_t h2o_socket_log_ssl_cipher(h2o_socket_t *sock, h2o_mem_pool_t *pool)
+{
+ const char *s = h2o_socket_get_ssl_cipher(sock);
+ return s != NULL ? h2o_iovec_init(s, strlen(s)) : h2o_iovec_init(NULL, 0);
+}
+
+inline int h2o_sliding_counter_is_running(h2o_sliding_counter_t *counter)
+{
+ return counter->cur.start_at != 0;
+}
+
+inline void h2o_sliding_counter_start(h2o_sliding_counter_t *counter, uint64_t now)
+{
+ counter->cur.start_at = now;
+}
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/debian/vendor-h2o/include/h2o/socket/evloop.h b/debian/vendor-h2o/include/h2o/socket/evloop.h
new file mode 100644
index 0000000..61ff29a
--- /dev/null
+++ b/debian/vendor-h2o/include/h2o/socket/evloop.h
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 2014 DeNA Co., Ltd.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+#ifndef h2o__evloop_h
+#define h2o__evloop_h
+
+#include "h2o/linklist.h"
+
+#define H2O_SOCKET_FLAG_IS_DISPOSED 0x1
+#define H2O_SOCKET_FLAG_IS_READ_READY 0x2
+#define H2O_SOCKET_FLAG_IS_WRITE_NOTIFY 0x4
+#define H2O_SOCKET_FLAG_IS_POLLED_FOR_READ 0x8
+#define H2O_SOCKET_FLAG_IS_POLLED_FOR_WRITE 0x10
+#define H2O_SOCKET_FLAG_DONT_READ 0x20
+#define H2O_SOCKET_FLAG_IS_CONNECTING 0x40
+#define H2O_SOCKET_FLAG_IS_ACCEPTED_CONNECTION 0x80
+#define H2O_SOCKET_FLAG__EPOLL_IS_REGISTERED 0x1000
+
+typedef struct st_h2o_evloop_t {
+ struct st_h2o_evloop_socket_t *_pending_as_client;
+ struct st_h2o_evloop_socket_t *_pending_as_server;
+ struct {
+ struct st_h2o_evloop_socket_t *head;
+ struct st_h2o_evloop_socket_t **tail_ref;
+ } _statechanged;
+ uint64_t _now;
+ h2o_linklist_t _timeouts; /* list of h2o_timeout_t */
+ h2o_sliding_counter_t exec_time_counter;
+} h2o_evloop_t;
+
+typedef h2o_evloop_t h2o_loop_t;
+
+struct st_h2o_timeout_backend_properties_t {
+ char _dummy; /* sizeof(empty_struct) differs bet. C (GCC extension) and C++ */
+};
+
+h2o_socket_t *h2o_evloop_socket_create(h2o_evloop_t *loop, int fd, int flags);
+h2o_socket_t *h2o_evloop_socket_accept(h2o_socket_t *listener);
+
+h2o_evloop_t *h2o_evloop_create(void);
+void h2o_evloop_destroy(h2o_evloop_t *loop);
+int h2o_evloop_run(h2o_evloop_t *loop, int32_t max_wait);
+
+/* inline definitions */
+
+static inline uint64_t h2o_now(h2o_evloop_t *loop)
+{
+ return loop->_now;
+}
+
+static inline uint64_t h2o_evloop_get_execution_time(h2o_evloop_t *loop)
+{
+ return loop->exec_time_counter.average;
+}
+
+#endif
diff --git a/debian/vendor-h2o/include/h2o/socket/uv-binding.h b/debian/vendor-h2o/include/h2o/socket/uv-binding.h
new file mode 100644
index 0000000..ad28122
--- /dev/null
+++ b/debian/vendor-h2o/include/h2o/socket/uv-binding.h
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2014 DeNA Co., Ltd.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+#ifndef h2o__uv_binding_h
+#define h2o__uv_binding_h
+
+#include <uv.h>
+
+#if !(defined(UV_VERSION_MAJOR) && UV_VERSION_MAJOR == 1)
+#error "libh2o (libuv binding) requires libuv version 1.x.y"
+#endif
+
+typedef uv_loop_t h2o_loop_t;
+
+struct st_h2o_timeout_backend_properties_t {
+ uv_timer_t timer;
+};
+
+h2o_socket_t *h2o_uv_socket_create(uv_stream_t *stream, uv_close_cb close_cb);
+
+static inline uint64_t h2o_now(uv_loop_t *loop)
+{
+ return uv_now(loop);
+}
+
+#endif
diff --git a/debian/vendor-h2o/include/h2o/socketpool.h b/debian/vendor-h2o/include/h2o/socketpool.h
new file mode 100644
index 0000000..cc4161d
--- /dev/null
+++ b/debian/vendor-h2o/include/h2o/socketpool.h
@@ -0,0 +1,120 @@
+/*
+ * Copyright (c) 2014 DeNA Co., Ltd.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+#ifndef h2o__socket_pool_h
+#define h2o__socket_pool_h
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <netinet/in.h>
+#include <arpa/inet.h>
+#include <pthread.h>
+#include "h2o/linklist.h"
+#include "h2o/multithread.h"
+#include "h2o/socket.h"
+#include "h2o/timeout.h"
+
+typedef enum en_h2o_socketpool_type_t { H2O_SOCKETPOOL_TYPE_NAMED, H2O_SOCKETPOOL_TYPE_SOCKADDR } h2o_socketpool_type_t;
+
+typedef struct st_h2o_socketpool_t {
+
+ /* read-only vars */
+ h2o_socketpool_type_t type;
+ struct {
+ h2o_iovec_t host;
+ union {
+ /* used to specify servname passed to getaddrinfo */
+ h2o_iovec_t named_serv;
+ /* if type is sockaddr, the `host` is not resolved but is used for TLS SNI and hostname verification */
+ struct {
+ struct sockaddr_storage bytes;
+ socklen_t len;
+ } sockaddr;
+ };
+ } peer;
+ int is_ssl;
+ size_t capacity;
+ uint64_t timeout; /* in milliseconds (UINT64_MAX if not set) */
+ struct {
+ h2o_loop_t *loop;
+ h2o_timeout_t timeout;
+ h2o_timeout_entry_t entry;
+ } _interval_cb;
+
+ /* vars that are modified by multiple threads */
+ struct {
+ size_t count; /* synchronous operations should be used to access the variable */
+ pthread_mutex_t mutex;
+ h2o_linklist_t sockets; /* guarded by the mutex; list of struct pool_entry_t defined in socket/pool.c */
+ } _shared;
+} h2o_socketpool_t;
+
+typedef struct st_h2o_socketpool_connect_request_t h2o_socketpool_connect_request_t;
+
+typedef void (*h2o_socketpool_connect_cb)(h2o_socket_t *sock, const char *errstr, void *data);
+/**
+ * initializes a socket loop
+ */
+void h2o_socketpool_init_by_address(h2o_socketpool_t *pool, struct sockaddr *sa, socklen_t salen, int is_ssl, size_t capacity);
+/**
+ * initializes a socket loop
+ */
+void h2o_socketpool_init_by_hostport(h2o_socketpool_t *pool, h2o_iovec_t host, uint16_t port, int is_ssl, size_t capacity);
+/**
+ * disposes of a socket loop
+ */
+void h2o_socketpool_dispose(h2o_socketpool_t *pool);
+/**
+ * sets a close timeout for the sockets being pooled
+ */
+void h2o_socketpool_set_timeout(h2o_socketpool_t *pool, h2o_loop_t *loop, uint64_t msec);
+/**
+ * connects to the peer (or returns a pooled connection)
+ */
+void h2o_socketpool_connect(h2o_socketpool_connect_request_t **req, h2o_socketpool_t *pool, h2o_loop_t *loop,
+ h2o_multithread_receiver_t *getaddr_receiver, h2o_socketpool_connect_cb cb, void *data);
+/**
+ * cancels a connect request
+ */
+void h2o_socketpool_cancel_connect(h2o_socketpool_connect_request_t *req);
+/**
+ * returns an idling socket to the socket pool
+ */
+int h2o_socketpool_return(h2o_socketpool_t *pool, h2o_socket_t *sock);
+/**
+ * determines if a socket belongs to the socket pool
+ */
+static int h2o_socketpool_is_owned_socket(h2o_socketpool_t *pool, h2o_socket_t *sock);
+
+/* inline defs */
+
+inline int h2o_socketpool_is_owned_socket(h2o_socketpool_t *pool, h2o_socket_t *sock)
+{
+ return sock->on_close.data == pool;
+}
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/debian/vendor-h2o/include/h2o/string_.h b/debian/vendor-h2o/include/h2o/string_.h
new file mode 100644
index 0000000..ca319e5
--- /dev/null
+++ b/debian/vendor-h2o/include/h2o/string_.h
@@ -0,0 +1,194 @@
+/*
+ * Copyright (c) 2014,2015 DeNA Co., Ltd., Kazuho Oku, Justin Zhu
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+#ifndef h2o__string_h
+#define h2o__string_h
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <stddef.h>
+#include <stdint.h>
+#include <time.h>
+#include "h2o/memory.h"
+
+#define H2O_STRLIT(s) (s), sizeof(s) - 1
+
+#define H2O_INT16_LONGEST_STR "-32768"
+#define H2O_UINT16_LONGEST_STR "65535"
+#define H2O_INT32_LONGEST_STR "-2147483648"
+#define H2O_UINT32_LONGEST_STR "4294967295"
+#define H2O_INT64_LONGEST_STR "-9223372036854775808"
+#define H2O_UINT64_LONGEST_STR "18446744073709551615"
+
+/**
+ * duplicates given string
+ * @param pool memory pool (or NULL to use malloc)
+ * @param s source string
+ * @param len length of the source string (the result of strlen(s) used in case len is SIZE_MAX)
+ * @return buffer pointing to the duplicated string (buf is NUL-terminated but the length does not include the NUL char)
+ */
+h2o_iovec_t h2o_strdup(h2o_mem_pool_t *pool, const char *s, size_t len);
+/**
+ * variant of h2o_strdup that calls h2o_mem_alloc_shared
+ */
+h2o_iovec_t h2o_strdup_shared(h2o_mem_pool_t *pool, const char *s, size_t len);
+/**
+ * duplicates given string appending '/' to the tail if not found
+ */
+h2o_iovec_t h2o_strdup_slashed(h2o_mem_pool_t *pool, const char *s, size_t len);
+/**
+ * tr/A-Z/a-z/
+ */
+static int h2o_tolower(int ch);
+/**
+ * tr/A-Z/a-z/
+ */
+static void h2o_strtolower(char *s, size_t len);
+/**
+ * tr/a-z/A-Z/
+ */
+static int h2o_toupper(int ch);
+/**
+ * tr/a-z/A-Z/
+ */
+static void h2o_strtoupper(char *s, size_t len);
+/**
+ * tests if target string (target_len bytes long) is equal to test string (test_len bytes long) after being converted to lower-case
+ */
+static int h2o_lcstris(const char *target, size_t target_len, const char *test, size_t test_len);
+/**
+ * turns the length of a string into the length of the same string encoded in base64
+ */
+static size_t h2o_base64_encode_capacity(size_t len);
+/**
+ * parses a positive number of return SIZE_MAX if failed
+ */
+size_t h2o_strtosize(const char *s, size_t len);
+/**
+ * parses first positive number contained in *s or return SIZE_MAX if failed.
+ * *s will set to right after the number in string or right after the end of string.
+ */
+size_t h2o_strtosizefwd(char **s, size_t len);
+/**
+ * base64 url decoder
+ */
+h2o_iovec_t h2o_decode_base64url(h2o_mem_pool_t *pool, const char *src, size_t len);
+/**
+ * base64 encoder (note: the function emits trailing '\0')
+ */
+size_t h2o_base64_encode(char *dst, const void *src, size_t len, int url_encoded);
+/**
+ * decodes hexadecimal string
+ */
+int h2o_hex_decode(void *dst, const char *src, size_t src_len);
+/**
+ * encodes binary into a hexadecimal string (with '\0' appended at last)
+ */
+void h2o_hex_encode(char *dst, const void *src, size_t src_len);
+/**
+ * URI-ecsapes given string (as defined in RFC 3986)
+ */
+h2o_iovec_t h2o_uri_escape(h2o_mem_pool_t *pool, const char *s, size_t l, const char *preserve_chars);
+/**
+ * returns the extension portion of path
+ */
+h2o_iovec_t h2o_get_filext(const char *path, size_t len);
+/**
+ * returns a vector with surrounding WS stripped
+ */
+h2o_iovec_t h2o_str_stripws(const char *s, size_t len);
+/**
+ * returns the offset of given substring or SIZE_MAX if not found
+ */
+size_t h2o_strstr(const char *haysack, size_t haysack_len, const char *needle, size_t needle_len);
+/**
+ *
+ */
+const char *h2o_next_token(h2o_iovec_t *iter, int separator, size_t *element_len, h2o_iovec_t *value);
+/**
+ * tests if string needle exists within a separator-separated string (for handling "#rule" of RFC 2616)
+ */
+int h2o_contains_token(const char *haysack, size_t haysack_len, const char *needle, size_t needle_len, int separator);
+/**
+ * HTML-escapes a string
+ * @param pool memory pool
+ * @param src source string
+ * @param len source length
+ * @return the escaped string, or the source itself if escape was not necessary
+ */
+h2o_iovec_t h2o_htmlescape(h2o_mem_pool_t *pool, const char *src, size_t len);
+/**
+ * concatenates a list of iovecs (with NUL termination)
+ */
+#define h2o_concat(pool, ...) \
+ h2o_concat_list(pool, (h2o_iovec_t[]){__VA_ARGS__}, sizeof((h2o_iovec_t[]){__VA_ARGS__}) / sizeof(h2o_iovec_t))
+h2o_iovec_t h2o_concat_list(h2o_mem_pool_t *pool, h2o_iovec_t *list, size_t count);
+/**
+ * emits a two-line string to buf that graphically points to given location within the source string
+ * @return 0 if successful
+ */
+int h2o_str_at_position(char *buf, const char *src, size_t src_len, int lineno, int column);
+
+int h2o__lcstris_core(const char *target, const char *test, size_t test_len);
+
+/* inline defs */
+
+inline int h2o_tolower(int ch)
+{
+ return 'A' <= ch && ch <= 'Z' ? ch + 0x20 : ch;
+}
+
+inline void h2o_strtolower(char *s, size_t len)
+{
+ for (; len != 0; ++s, --len)
+ *s = h2o_tolower(*s);
+}
+
+inline int h2o_toupper(int ch)
+{
+ return 'a' <= ch && ch <= 'z' ? ch - 0x20 : ch;
+}
+
+inline void h2o_strtoupper(char *s, size_t len)
+{
+ for (; len != 0; ++s, --len)
+ *s = h2o_toupper(*s);
+}
+
+inline int h2o_lcstris(const char *target, size_t target_len, const char *test, size_t test_len)
+{
+ if (target_len != test_len)
+ return 0;
+ return h2o__lcstris_core(target, test, test_len);
+}
+
+inline size_t h2o_base64_encode_capacity(size_t len)
+{
+ return (((len) + 2) / 3 * 4 + 1);
+}
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/debian/vendor-h2o/include/h2o/time_.h b/debian/vendor-h2o/include/h2o/time_.h
new file mode 100644
index 0000000..1bab3ef
--- /dev/null
+++ b/debian/vendor-h2o/include/h2o/time_.h
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2015 DeNA Co., Ltd.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+#ifndef h2o__time_h
+#define h2o__time_h
+
+#include <stdint.h>
+#include <sys/time.h>
+#include <time.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define H2O_TIMESTR_RFC1123_LEN (sizeof("Sun, 06 Nov 1994 08:49:37 GMT") - 1)
+#define H2O_TIMESTR_LOG_LEN (sizeof("29/Aug/2014:15:34:38 +0900") - 1)
+
+/**
+ * builds a RFC-1123 style date string
+ */
+void h2o_time2str_rfc1123(char *buf, struct tm *gmt);
+/**
+ * converts HTTP-date to packed format (or returns UINT64_MAX on failure)
+ */
+int h2o_time_parse_rfc1123(const char *s, size_t len, struct tm *tm);
+/**
+ * builds an Apache log-style date string
+ */
+void h2o_time2str_log(char *buf, time_t time);
+
+static inline int64_t h2o_timeval_subtract(struct timeval *from, struct timeval *until)
+{
+ int32_t delta_sec = (int32_t)until->tv_sec - (int32_t)from->tv_sec;
+ int32_t delta_usec = (int32_t)until->tv_usec - (int32_t)from->tv_usec;
+ int64_t delta = (int64_t)((int64_t)delta_sec * 1000 * 1000L) + delta_usec;
+
+ return delta;
+}
+
+static inline int h2o_timeval_is_null(struct timeval *tv)
+{
+ return tv->tv_sec == 0;
+}
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/debian/vendor-h2o/include/h2o/timeout.h b/debian/vendor-h2o/include/h2o/timeout.h
new file mode 100644
index 0000000..59e65f0
--- /dev/null
+++ b/debian/vendor-h2o/include/h2o/timeout.h
@@ -0,0 +1,99 @@
+/*
+ * Copyright (c) 2014 DeNA Co., Ltd.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+#ifndef h2o__timeout_h
+#define h2o__timeout_h
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <stdint.h>
+#include "h2o/linklist.h"
+#include "h2o/socket.h"
+
+typedef struct st_h2o_timeout_entry_t h2o_timeout_entry_t;
+typedef void (*h2o_timeout_cb)(h2o_timeout_entry_t *entry);
+
+/**
+ * an entry linked to h2o_timeout_t.
+ * Modules willing to use timeouts should embed this object as part of itself, and link it to a specific timeout by calling
+ * h2o_timeout_link.
+ */
+struct st_h2o_timeout_entry_t {
+ uint64_t registered_at;
+ h2o_timeout_cb cb;
+ h2o_linklist_t _link;
+};
+
+/**
+ * represents a collection of h2o_timeout_entry_t linked to a single timeout value
+ */
+typedef struct st_h2o_timeout_t {
+ uint64_t timeout;
+ h2o_linklist_t _link;
+ h2o_linklist_t _entries; /* link list of h2o_timeout_entry_t */
+ struct st_h2o_timeout_backend_properties_t _backend;
+} h2o_timeout_t;
+
+/**
+ * initializes and registers a timeout
+ * @param loop loop to which the timeout should be registered
+ * @param timeout the timeout structure to be initialized
+ * @param millis timeout in milliseconds
+ */
+void h2o_timeout_init(h2o_loop_t *loop, h2o_timeout_t *timeout, uint64_t millis);
+/**
+ *
+ */
+void h2o_timeout_dispose(h2o_loop_t *loop, h2o_timeout_t *timeout);
+/**
+ * activates a timeout entry, by linking it to a timeout
+ */
+void h2o_timeout_link(h2o_loop_t *loop, h2o_timeout_t *timeout, h2o_timeout_entry_t *entry);
+/**
+ * deactivates a timeout entry, by unlinking it from a timeout
+ */
+void h2o_timeout_unlink(h2o_timeout_entry_t *entry);
+/**
+ * returns a boolean value indicating if the timeout is linked (i.e. active) or not
+ */
+static int h2o_timeout_is_linked(h2o_timeout_entry_t *entry);
+
+void h2o_timeout_run(h2o_loop_t *loop, h2o_timeout_t *timeout, uint64_t now);
+uint64_t h2o_timeout_get_wake_at(h2o_linklist_t *timeouts);
+void h2o_timeout__do_init(h2o_loop_t *loop, h2o_timeout_t *timeout);
+void h2o_timeout__do_dispose(h2o_loop_t *loop, h2o_timeout_t *timeout);
+void h2o_timeout__do_link(h2o_loop_t *loop, h2o_timeout_t *timeout, h2o_timeout_entry_t *entry);
+void h2o_timeout__do_post_callback(h2o_loop_t *loop);
+
+/* inline defs */
+
+inline int h2o_timeout_is_linked(h2o_timeout_entry_t *entry)
+{
+ return h2o_linklist_is_linked(&entry->_link);
+}
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/debian/vendor-h2o/include/h2o/token.h b/debian/vendor-h2o/include/h2o/token.h
new file mode 100644
index 0000000..1946b8b
--- /dev/null
+++ b/debian/vendor-h2o/include/h2o/token.h
@@ -0,0 +1,90 @@
+/*
+ * Copyright (c) 2014 DeNA Co., Ltd.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the &quot;Software&quot;), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED &quot;AS IS&quot;, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+/* DO NOT EDIT! generated by tokens.pl */
+#ifndef h2o__token_h
+#define h2o__token_h
+
+#define H2O_TOKEN_AUTHORITY (h2o__tokens + 0)
+#define H2O_TOKEN_METHOD (h2o__tokens + 1)
+#define H2O_TOKEN_PATH (h2o__tokens + 2)
+#define H2O_TOKEN_SCHEME (h2o__tokens + 3)
+#define H2O_TOKEN_STATUS (h2o__tokens + 4)
+#define H2O_TOKEN_ACCEPT (h2o__tokens + 5)
+#define H2O_TOKEN_ACCEPT_CHARSET (h2o__tokens + 6)
+#define H2O_TOKEN_ACCEPT_ENCODING (h2o__tokens + 7)
+#define H2O_TOKEN_ACCEPT_LANGUAGE (h2o__tokens + 8)
+#define H2O_TOKEN_ACCEPT_RANGES (h2o__tokens + 9)
+#define H2O_TOKEN_ACCESS_CONTROL_ALLOW_ORIGIN (h2o__tokens + 10)
+#define H2O_TOKEN_AGE (h2o__tokens + 11)
+#define H2O_TOKEN_ALLOW (h2o__tokens + 12)
+#define H2O_TOKEN_AUTHORIZATION (h2o__tokens + 13)
+#define H2O_TOKEN_CACHE_CONTROL (h2o__tokens + 14)
+#define H2O_TOKEN_CACHE_DIGEST (h2o__tokens + 15)
+#define H2O_TOKEN_CONNECTION (h2o__tokens + 16)
+#define H2O_TOKEN_CONTENT_DISPOSITION (h2o__tokens + 17)
+#define H2O_TOKEN_CONTENT_ENCODING (h2o__tokens + 18)
+#define H2O_TOKEN_CONTENT_LANGUAGE (h2o__tokens + 19)
+#define H2O_TOKEN_CONTENT_LENGTH (h2o__tokens + 20)
+#define H2O_TOKEN_CONTENT_LOCATION (h2o__tokens + 21)
+#define H2O_TOKEN_CONTENT_RANGE (h2o__tokens + 22)
+#define H2O_TOKEN_CONTENT_TYPE (h2o__tokens + 23)
+#define H2O_TOKEN_COOKIE (h2o__tokens + 24)
+#define H2O_TOKEN_DATE (h2o__tokens + 25)
+#define H2O_TOKEN_ETAG (h2o__tokens + 26)
+#define H2O_TOKEN_EXPECT (h2o__tokens + 27)
+#define H2O_TOKEN_EXPIRES (h2o__tokens + 28)
+#define H2O_TOKEN_FROM (h2o__tokens + 29)
+#define H2O_TOKEN_HOST (h2o__tokens + 30)
+#define H2O_TOKEN_HTTP2_SETTINGS (h2o__tokens + 31)
+#define H2O_TOKEN_IF_MATCH (h2o__tokens + 32)
+#define H2O_TOKEN_IF_MODIFIED_SINCE (h2o__tokens + 33)
+#define H2O_TOKEN_IF_NONE_MATCH (h2o__tokens + 34)
+#define H2O_TOKEN_IF_RANGE (h2o__tokens + 35)
+#define H2O_TOKEN_IF_UNMODIFIED_SINCE (h2o__tokens + 36)
+#define H2O_TOKEN_KEEP_ALIVE (h2o__tokens + 37)
+#define H2O_TOKEN_LAST_MODIFIED (h2o__tokens + 38)
+#define H2O_TOKEN_LINK (h2o__tokens + 39)
+#define H2O_TOKEN_LOCATION (h2o__tokens + 40)
+#define H2O_TOKEN_MAX_FORWARDS (h2o__tokens + 41)
+#define H2O_TOKEN_PROXY_AUTHENTICATE (h2o__tokens + 42)
+#define H2O_TOKEN_PROXY_AUTHORIZATION (h2o__tokens + 43)
+#define H2O_TOKEN_RANGE (h2o__tokens + 44)
+#define H2O_TOKEN_REFERER (h2o__tokens + 45)
+#define H2O_TOKEN_REFRESH (h2o__tokens + 46)
+#define H2O_TOKEN_RETRY_AFTER (h2o__tokens + 47)
+#define H2O_TOKEN_SERVER (h2o__tokens + 48)
+#define H2O_TOKEN_SET_COOKIE (h2o__tokens + 49)
+#define H2O_TOKEN_STRICT_TRANSPORT_SECURITY (h2o__tokens + 50)
+#define H2O_TOKEN_TE (h2o__tokens + 51)
+#define H2O_TOKEN_TRANSFER_ENCODING (h2o__tokens + 52)
+#define H2O_TOKEN_UPGRADE (h2o__tokens + 53)
+#define H2O_TOKEN_USER_AGENT (h2o__tokens + 54)
+#define H2O_TOKEN_VARY (h2o__tokens + 55)
+#define H2O_TOKEN_VIA (h2o__tokens + 56)
+#define H2O_TOKEN_WWW_AUTHENTICATE (h2o__tokens + 57)
+#define H2O_TOKEN_X_COMPRESS_HINT (h2o__tokens + 58)
+#define H2O_TOKEN_X_FORWARDED_FOR (h2o__tokens + 59)
+#define H2O_TOKEN_X_REPROXY_URL (h2o__tokens + 60)
+#define H2O_TOKEN_X_TRAFFIC (h2o__tokens + 61)
+
+#endif
diff --git a/debian/vendor-h2o/include/h2o/tunnel.h b/debian/vendor-h2o/include/h2o/tunnel.h
new file mode 100644
index 0000000..520de91
--- /dev/null
+++ b/debian/vendor-h2o/include/h2o/tunnel.h
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2015 Justin Zhu, DeNA Co., Ltd., Kazuho Oku
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+#ifndef h2o__tunnel_h
+#define h2o__tunnel_h
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct st_h2o_tunnel_t h2o_tunnel_t;
+
+h2o_tunnel_t *h2o_tunnel_establish(h2o_context_t *ctx, h2o_socket_t *sock1, h2o_socket_t *sock2, h2o_timeout_t *timeout);
+void h2o_tunnel_break(h2o_tunnel_t *tunnel);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/debian/vendor-h2o/include/h2o/url.h b/debian/vendor-h2o/include/h2o/url.h
new file mode 100644
index 0000000..231c9a2
--- /dev/null
+++ b/debian/vendor-h2o/include/h2o/url.h
@@ -0,0 +1,147 @@
+/*
+ * Copyright (c) 2014,2015 DeNA Co., Ltd.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+#ifndef h2o__url_h
+#define h2o__url_h
+
+#include <sys/un.h>
+#include "h2o/memory.h"
+
+typedef struct st_h2o_url_scheme_t {
+ h2o_iovec_t name;
+ uint16_t default_port;
+} h2o_url_scheme_t;
+
+extern const h2o_url_scheme_t H2O_URL_SCHEME_HTTP, H2O_URL_SCHEME_HTTPS;
+
+typedef struct st_h2o_url_t {
+ const h2o_url_scheme_t *scheme;
+ h2o_iovec_t authority; /* i.e. host:port */
+ h2o_iovec_t host;
+ h2o_iovec_t path;
+ uint16_t _port;
+} h2o_url_t;
+
+/**
+ * retrieves the port number from url
+ */
+static uint16_t h2o_url_get_port(const h2o_url_t *url);
+/**
+ * removes "..", ".", decodes %xx from a path representation
+ * @param pool memory pool to be used in case the path contained references to directories
+ * @param path source path
+ * @param len source length
+ * @param returns offset of '?' within `path` if found, or SIZE_MAX if not
+ * @param indexes mapping the normalized version to the input version
+ * @return buffer pointing to source, or buffer pointing to an allocated chunk with normalized representation of the given path
+ */
+h2o_iovec_t h2o_url_normalize_path(h2o_mem_pool_t *pool, const char *path, size_t len, size_t *query_at, size_t **norm_indexes);
+/**
+ * initializes URL object given scheme, authority, and path
+ * @param the output
+ * @param scheme scheme
+ * @param authority
+ * @param path
+ * @return 0 if successful
+ */
+static int h2o_url_init(h2o_url_t *url, const h2o_url_scheme_t *scheme, h2o_iovec_t authority, h2o_iovec_t path);
+/**
+ * parses absolute URL (either http or https)
+ */
+int h2o_url_parse(const char *url, size_t url_len, h2o_url_t *result);
+/**
+ * parses relative URL
+ */
+int h2o_url_parse_relative(const char *url, size_t url_len, h2o_url_t *result);
+/**
+ * parses the authority and returns the next position (i.e. start of path)
+ * @return pointer to the end of hostport if successful, or NULL if failed. *port becomes the specified port number or 65535 if not
+ */
+const char *h2o_url_parse_hostport(const char *s, size_t len, h2o_iovec_t *host, uint16_t *port);
+/**
+ * resolves the URL (stored to `dest` as well as returning the stringified representation (always allocated using pool)
+ */
+h2o_iovec_t h2o_url_resolve(h2o_mem_pool_t *pool, const h2o_url_t *base, const h2o_url_t *relative, h2o_url_t *dest);
+/**
+ * resolves the path part of the URL (both the arguments are modified; the result is h2o_concat(*base, *relative))
+ */
+void h2o_url_resolve_path(h2o_iovec_t *base, h2o_iovec_t *relative);
+/**
+ * stringifies the URL
+ */
+static h2o_iovec_t h2o_url_stringify(h2o_mem_pool_t *pool, const h2o_url_t *url);
+/**
+ * copies a URL object (null-terminates all the string elements)
+ */
+void h2o_url_copy(h2o_mem_pool_t *pool, h2o_url_t *dest, const h2o_url_t *src);
+/**
+ * extracts sockaddr_un from host and returns NULL (or returns an error string if failed)
+ */
+const char *h2o_url_host_to_sun(h2o_iovec_t host, struct sockaddr_un *sa);
+extern const char *h2o_url_host_to_sun_err_is_not_unix_socket;
+
+/* inline definitions */
+
+inline int h2o_url_init(h2o_url_t *url, const h2o_url_scheme_t *scheme, h2o_iovec_t authority, h2o_iovec_t path)
+{
+ if (h2o_url_parse_hostport(authority.base, authority.len, &url->host, &url->_port) != authority.base + authority.len)
+ return -1;
+ url->scheme = scheme;
+ url->authority = authority;
+ url->path = path;
+ return 0;
+}
+
+inline uint16_t h2o_url_get_port(const h2o_url_t *url)
+{
+ return url->_port != 65535 ? url->_port : url->scheme->default_port;
+}
+
+inline h2o_iovec_t h2o_url_stringify(h2o_mem_pool_t *pool, const h2o_url_t *url)
+{
+ h2o_url_t tmp;
+ return h2o_url_resolve(pool, url, NULL, &tmp);
+}
+
+static inline int h2o_url_host_is_unix_path(h2o_iovec_t host)
+{
+ if (host.len < 5) {
+ return 0;
+ }
+ return h2o_memis(host.base, 5, H2O_STRLIT("unix:"));
+}
+
+/**
+ * Compares to hostnames, taking into account whether they contain a
+ * unix path (the comparison will be case sensitive) or not.
+ */
+static inline int h2o_url_hosts_are_equal(const h2o_url_t *url_a, const h2o_url_t *url_b)
+{
+ if (url_a->host.len != url_b->host.len)
+ return 0;
+
+ if (h2o_url_host_is_unix_path(url_a->host))
+ return h2o_memis(url_a->host.base, url_a->host.len, url_b->host.base, url_b->host.len);
+ else
+ return h2o_lcstris(url_a->host.base, url_a->host.len, url_b->host.base, url_b->host.len);
+}
+
+#endif
diff --git a/debian/vendor-h2o/include/h2o/version.h b/debian/vendor-h2o/include/h2o/version.h
new file mode 100644
index 0000000..0299197
--- /dev/null
+++ b/debian/vendor-h2o/include/h2o/version.h
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2014,2015 DeNA Co., Ltd.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+#ifndef h2o__version_h
+#define h2o__version_h
+
+#define H2O_VERSION "2.2.6"
+
+#define H2O_VERSION_MAJOR 2
+#define H2O_VERSION_MINOR 2
+#define H2O_VERSION_PATCH 6
+
+#define H2O_LIBRARY_VERSION_MAJOR 0
+#define H2O_LIBRARY_VERSION_MINOR 13
+#define H2O_LIBRARY_VERSION_PATCH 6
+
+#endif
diff --git a/debian/vendor-h2o/include/h2o/websocket.h b/debian/vendor-h2o/include/h2o/websocket.h
new file mode 100644
index 0000000..96e047a
--- /dev/null
+++ b/debian/vendor-h2o/include/h2o/websocket.h
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2014 DeNA Co., Ltd.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+#ifndef h2o__websocket_h
+#define h2o__websocket_h
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <wslay/wslay.h>
+#include "h2o.h"
+#include "h2o/http1.h"
+
+typedef struct st_h2o_websocket_conn_t h2o_websocket_conn_t;
+
+/* arg is NULL if the connection has been closed */
+typedef void (*h2o_websocket_msg_callback)(h2o_websocket_conn_t *conn, const struct wslay_event_on_msg_recv_arg *arg);
+
+struct st_h2o_websocket_conn_t {
+ h2o_socket_t *sock;
+ wslay_event_context_ptr ws_ctx;
+ struct wslay_event_callbacks ws_callbacks;
+ void *data;
+ h2o_websocket_msg_callback cb;
+ void *_write_buf;
+};
+
+int h2o_is_websocket_handshake(h2o_req_t *req, const char **client_key);
+void h2o_websocket_create_accept_key(char *dst, const char *client_key);
+h2o_websocket_conn_t *h2o_upgrade_to_websocket(h2o_req_t *req, const char *client_key, void *user_data,
+ h2o_websocket_msg_callback msg_cb);
+void h2o_websocket_close(h2o_websocket_conn_t *conn);
+void h2o_websocket_proceed(h2o_websocket_conn_t *conn);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif