➜ h2o git:(master) sw_vers ProductName: Mac OS X ProductVersion: 10.9.5 BuildVersion: 13F34 ➜ h2o git:(master) openssl version OpenSSL 0.9.8za 5 Jun 2014 ➜ h2o git:(master) git checkout refs/tags/v1.2.0 -b v1.2.0 Switched to a new branch 'v1.2.0' ➜ h2o git:(v1.2.0) vim examples/libh2o/simple.c 1 /* 2 * Copyright (c) 2014 DeNA Co., Ltd. 3 * 4 * Permission is hereby granted, free of charge, to any person obtaining a copy 5 * of this software and associated documentation files (the "Software"), to 6 * deal in the Software without restriction, including without limitation the 7 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 8 * sell copies of the Software, and to permit persons to whom the Software is 9 * furnished to do so, subject to the following conditions: 10 * 11 * The above copyright notice and this permission notice shall be included in 12 * all copies or substantial portions of the Software. 13 * 14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 19 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 20 * IN THE SOFTWARE. 21 */ 22 #include 23 #include 24 #include 25 #include 26 #include 27 #include 28 #include 29 #include 30 #include "h2o.h" 31 #include "h2o/http1.h" 32 #include "h2o/http2.h" 33 34 static h2o_pathconf_t *register_handler(h2o_hostconf_t *hostconf, const char *path, int (*on_req)(h2o_handler_t *, h2o_req_t *)) 35 { 36 h2o_pathconf_t *pathconf = h2o_config_register_path(hostconf, path); 37 h2o_handler_t *handler = h2o_create_handler(pathconf, sizeof(*handler)); 38 handler->on_req = on_req; 39 return pathconf; 40 } 41 42 static int chunked_test(h2o_handler_t *self, h2o_req_t *req) 43 { 44 static h2o_generator_t generator = {NULL, NULL}; 45 46 if (!h2o_memis(req->method.base, req->method.len, H2O_STRLIT("GET"))) 47 return -1; 48 49 h2o_iovec_t body = h2o_strdup(&req->pool, "hello world\n", SIZE_MAX); 50 req->res.status = 200; 51 req->res.reason = "OK"; 52 h2o_add_header(&req->pool, &req->res.headers, H2O_TOKEN_CONTENT_TYPE, H2O_STRLIT("text/plain")); 53 h2o_start_response(req, &generator); "examples/libh2o/simple.c" 258L, 7922C 205 h2o_ssl_register_npn_protocols(ssl_ctx, h2o_http2_npn_protocols); 206 #endif 207 #if H2O_USE_ALPN 208 h2o_ssl_register_alpn_protocols(ssl_ctx, h2o_http2_alpn_protocols); 209 #endif 210 211 return 0; 212 } 213 214 int main(int argc, char **argv) 215 { 216 h2o_hostconf_t *hostconf; 217 218 signal(SIGPIPE, SIG_IGN); 219 220 h2o_config_init(&config); 221 hostconf = h2o_config_register_host(&config, "default"); 222 register_handler(hostconf, "/post-test", post_test); 223 register_handler(hostconf, "/chunked-test", chunked_test); 224 h2o_reproxy_register(register_handler(hostconf, "/reproxy-test", reproxy_test)); 225 h2o_file_register(h2o_config_register_path(hostconf, "/"), "examples/doc_root", NULL, NULL, 0); 226 227 #if H2O_USE_LIBUV 228 uv_loop_t loop; 229 uv_loop_init(&loop); 230 h2o_context_init(&ctx, &loop, &config); 231 #else 232 h2o_context_init(&ctx, h2o_evloop_create(), &config); 233 #endif 234 235 /* disabled by default: uncomment the block below to use HTTPS instead of HTTP */ 236 if (setup_ssl("examples/h2o/server.crt", "examples/h2o/server.key") != 0) 237 goto Error; 238 239 /* disabled by default: uncomment the line below to enable access logging */ 240 /* h2o_access_log_register(&config.default_host, "/dev/stdout", NULL); */ 241 242 if (create_listener() != 0) { 243 fprintf(stderr, "failed to listen to 127.0.0.1:7890:%s\n", strerror(errno)); 244 goto Error; 245 } 246 247 #if H2O_USE_LIBUV 248 uv_run(ctx.loop, UV_RUN_DEFAULT); 249 #else 250 while (h2o_evloop_run(ctx.loop) == 0) 251 ; 252 #endif 253 254 Error: 255 return 1; 256 } ~ ~ "examples/libh2o/simple.c" 256L, 7934C written ➜ h2o git:(v1.2.0) ✗ git diff ➜ h2o git:(v1.2.0) ✗ cmake -DWITH_BUNDLED_SSL=on . && make lib-examples -- checking for module 'libwslay' -- package 'libwslay' not found -- Could NOT find WSLAY (missing: WSLAY_LIBRARIES WSLAY_INCLUDE_DIR) -- Configuring done -- Generating done -- Build files have been written to: /tmp/h2o Scanning dependencies of target libh2o [ 4%] Building C object CMakeFiles/libh2o.dir/lib/core/config.c.o [ 4%] Building C object CMakeFiles/libh2o.dir/lib/core/configurator.c.o [ 8%] Building C object CMakeFiles/libh2o.dir/lib/core/context.c.o [ 8%] Building C object CMakeFiles/libh2o.dir/lib/core/headers.c.o [ 13%] Building C object CMakeFiles/libh2o.dir/lib/core/proxy.c.o [ 13%] Building C object CMakeFiles/libh2o.dir/lib/core/request.c.o [ 17%] Building C object CMakeFiles/libh2o.dir/lib/core/token.c.o [ 17%] Building C object CMakeFiles/libh2o.dir/lib/core/util.c.o [ 21%] Building C object CMakeFiles/libh2o.dir/lib/handler/access_log.c.o [ 21%] Building C object CMakeFiles/libh2o.dir/lib/handler/chunked.c.o [ 26%] Building C object CMakeFiles/libh2o.dir/lib/handler/expires.c.o [ 30%] Building C object CMakeFiles/libh2o.dir/lib/handler/file.c.o [ 30%] Building C object CMakeFiles/libh2o.dir/lib/handler/headers.c.o [ 34%] Building C object CMakeFiles/libh2o.dir/lib/handler/mimemap.c.o [ 34%] Building C object CMakeFiles/libh2o.dir/lib/handler/proxy.c.o [ 39%] Building C object CMakeFiles/libh2o.dir/lib/handler/redirect.c.o [ 39%] Building C object CMakeFiles/libh2o.dir/lib/handler/reproxy.c.o [ 43%] Building C object CMakeFiles/libh2o.dir/lib/handler/configurator/access_log.c.o [ 43%] Building C object CMakeFiles/libh2o.dir/lib/handler/configurator/expires.c.o [ 47%] Building C object CMakeFiles/libh2o.dir/lib/handler/configurator/file.c.o [ 47%] Building C object CMakeFiles/libh2o.dir/lib/handler/configurator/headers.c.o [ 52%] Building C object CMakeFiles/libh2o.dir/lib/handler/configurator/proxy.c.o [ 52%] Building C object CMakeFiles/libh2o.dir/lib/handler/configurator/redirect.c.o [ 56%] Building C object CMakeFiles/libh2o.dir/lib/handler/configurator/reproxy.c.o [ 60%] Building C object CMakeFiles/libh2o.dir/lib/http1.c.o [ 60%] Building C object CMakeFiles/libh2o.dir/lib/http2/connection.c.o [ 65%] Building C object CMakeFiles/libh2o.dir/lib/http2/frame.c.o [ 65%] Building C object CMakeFiles/libh2o.dir/lib/http2/hpack.c.o [ 69%] Building C object CMakeFiles/libh2o.dir/lib/http2/scheduler.c.o [ 69%] Building C object CMakeFiles/libh2o.dir/lib/http2/stream.c.o Linking C static library libh2o.a [ 95%] Built target libh2o Linking C executable examples-http1client [ 95%] Built target examples-http1client Linking C executable examples-socket-client [ 95%] Built target examples-socket-client Scanning dependencies of target examples-simple [100%] Building C object CMakeFiles/examples-simple.dir/examples/libh2o/simple.c.o /tmp/h2o/examples/libh2o/simple.c:186:5: warning: 'SSL_load_error_strings' is deprecated: first deprecated in OS X 10.7 [-Wdeprecated-declarations] SSL_load_error_strings(); ^ /usr/include/openssl/ssl.h:1421:6: note: 'SSL_load_error_strings' has been explicitly marked deprecated here void SSL_load_error_strings(void ) DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER; ^ /tmp/h2o/examples/libh2o/simple.c:187:5: warning: 'SSL_library_init' is deprecated: first deprecated in OS X 10.7 [-Wdeprecated-declarations] SSL_library_init(); ^ /usr/include/openssl/ssl.h:1558:5: note: 'SSL_library_init' has been explicitly marked deprecated here int SSL_library_init(void ) DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER; ^ /tmp/h2o/examples/libh2o/simple.c:188:5: warning: 'OPENSSL_add_all_algorithms_noconf' is deprecated: first deprecated in OS X 10.7 [-Wdeprecated-declarations] OpenSSL_add_all_algorithms(); ^ /usr/include/openssl/evp.h:829:3: note: expanded from macro 'OpenSSL_add_all_algorithms' OPENSSL_add_all_algorithms_noconf() ^ /usr/include/openssl/evp.h:821:6: note: 'OPENSSL_add_all_algorithms_noconf' has been explicitly marked deprecated here void OPENSSL_add_all_algorithms_noconf(void) DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER; ^ /tmp/h2o/examples/libh2o/simple.c:190:15: warning: 'SSL_CTX_new' is deprecated: first deprecated in OS X 10.7 [-Wdeprecated-declarations] ssl_ctx = SSL_CTX_new(SSLv23_server_method()); ^ /usr/include/openssl/ssl.h:1351:10: note: 'SSL_CTX_new' has been explicitly marked deprecated here SSL_CTX *SSL_CTX_new(SSL_METHOD *meth) DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER; ^ /tmp/h2o/examples/libh2o/simple.c:190:27: warning: 'SSLv23_server_method' is deprecated: first deprecated in OS X 10.7 [-Wdeprecated-declarations] ssl_ctx = SSL_CTX_new(SSLv23_server_method()); ^ /usr/include/openssl/ssl.h:1521:13: note: 'SSLv23_server_method' has been explicitly marked deprecated here SSL_METHOD *SSLv23_server_method(void) DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER; /* SSLv3 but can rollb... ^ /tmp/h2o/examples/libh2o/simple.c:191:5: warning: 'SSL_CTX_ctrl' is deprecated: first deprecated in OS X 10.7 [-Wdeprecated-declarations] SSL_CTX_set_options(ssl_ctx, SSL_OP_NO_SSLv2); ^ /usr/include/openssl/ssl.h:574:2: note: expanded from macro 'SSL_CTX_set_options' SSL_CTX_ctrl((ctx),SSL_CTRL_OPTIONS,(op),NULL) ^ /usr/include/openssl/ssl.h:1503:6: note: 'SSL_CTX_ctrl' has been explicitly marked deprecated here long SSL_CTX_ctrl(SSL_CTX *ctx,int cmd, long larg, void *parg) DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER; ^ /tmp/h2o/examples/libh2o/simple.c:194:9: warning: 'SSL_CTX_use_certificate_file' is deprecated: first deprecated in OS X 10.7 [-Wdeprecated-declarations] if (SSL_CTX_use_certificate_file(ssl_ctx, cert_file, SSL_FILETYPE_PEM) != 1) { ^ /usr/include/openssl/ssl.h:1407:5: note: 'SSL_CTX_use_certificate_file' has been explicitly marked deprecated here int SSL_CTX_use_certificate_file(SSL_CTX *ctx, const char *file, int type) DEPRECATED_IN_MAC_OS_X_VERSION_... ^ /tmp/h2o/examples/libh2o/simple.c:198:9: warning: 'SSL_CTX_use_PrivateKey_file' is deprecated: first deprecated in OS X 10.7 [-Wdeprecated-declarations] if (SSL_CTX_use_PrivateKey_file(ssl_ctx, key_file, SSL_FILETYPE_PEM) != 1) { ^ /usr/include/openssl/ssl.h:1406:5: note: 'SSL_CTX_use_PrivateKey_file' has been explicitly marked deprecated here int SSL_CTX_use_PrivateKey_file(SSL_CTX *ctx, const char *file, int type) DEPRECATED_IN_MAC_OS_X_VERSION_1... ^ 8 warnings generated. Linking C executable examples-simple [100%] Built target examples-simple [100%] Built target lib-examples