Commit Graph

363 Commits

Author SHA1 Message Date
Tatsuhiro Tsujikawa d0c27d5229 Send 24 bytes client magic byte string by library
Previously nghttp2_session_send() and nghttp2_session_mem_send() did
not send 24 bytes client magic byte string (MAGIC).  We made
nghttp2_session_recv() and nghttp2_session_mem_recv() process MAGIC by
default, so it is natural to make library send MAGIC as well.  This
commit makes nghttp2_session_send() and nghttp2_session_mem_send()
send MAGIC.  This commit also replace "connection preface" with
"client magic", since we call MAGIC as "connection preface" but it is
just a part of connection preface.  NGHTTP2_CLIENT_CONNECTION_PREFACE
macro was replaced with NGHTTP2_CLIENT_MAGIC.  The already deprecated
NGHTTP2_CLIENT_CONNECTION_HEADER macro was removed permanently.
nghttp2_option_set_no_recv_client_preface() was renamed as
nghttp2_option_set_no_recv_client_magic().  NGHTTP2_ERR_BAD_PREFACE
was renamed as NGHTTP2_ERR_BAD_CLIENT_MAGIC.
2015-04-05 23:15:20 +09:00
Tatsuhiro Tsujikawa 250ea53e4b Deal with 24 bytes client connection preface by default
Since HTTP/2 spec requires for client to send connection preface, it
is reasonable to make this option enabled by default.  It is still a
use case to disable this, so replace this option with
nghttp2_option_set_no_recv_client_preface().
2015-04-05 23:15:20 +09:00
Tatsuhiro Tsujikawa 7522d50d1a nghttpd, tiny-nghttpd: No need to check existence of stream
The stream existence is guaranteed by library as of
cc03a12b75.
2015-04-05 23:13:29 +09:00
Tatsuhiro Tsujikawa 9eff511c5e Add nghttp2_send_data_callback to send DATA payload without copying
To avoid buffer copy in nghttp2_data_source_read_callback, this commit
introduces NGHTTP2_DATA_FLAG_NO_COPY and nghttp2_send_data_callback.
By using NGHTTP2_DATA_FLAG_NO_COPY in
nghttp2_data_source_read_callback, application can avoid to copy
application data to given buffer.  Instead, application has to
implement nghttp2_send_data_callback to send complete DATA frame by
itself.  We see noticeable performance increase in nghttpd and
tiny-nghttpd using this new feature.  On the other hand, nghttpx does
not show such difference, probably because buffer copy is not
bottleneck.  Using nghttp2_send_data_callback adds complexity, so it
is recommended to measure the performance to see whether this extra
complexity worth it.
2015-04-04 21:23:50 +09:00
Tatsuhiro Tsujikawa c2510a01a5 examples: Place AM_CPPFLAGS first to use in-package header files first
Fixes GH-192
2015-03-26 23:09:39 +09:00
Tatsuhiro Tsujikawa c976a0fcd1 asio: Add server::response::write_trailer() 2015-03-07 19:26:42 +09:00
Tatsuhiro Tsujikawa 66f5438dc9 asio: Remove eof check in asio-cl.cc 2015-03-07 03:10:37 +09:00
Tatsuhiro Tsujikawa 45164b6761 asio: asio-cl: Shutdown session on closure of first stream 2015-03-07 01:42:01 +09:00
Tatsuhiro Tsujikawa ceefddd332 asio: Remove unused captured variable 2015-03-07 01:39:25 +09:00
Tatsuhiro Tsujikawa b24bd3d8cb asio: Use host_service_from_uri in asio-cl2.cc 2015-03-07 01:10:49 +09:00
Tatsuhiro Tsujikawa 5dccc88a7c asio: Add host_service_from_uri() to extract remote address from URI 2015-03-07 01:10:49 +09:00
Tatsuhiro Tsujikawa d7cfe464a2 asio: client::configure_tls_context takes error_code 2015-03-07 01:10:49 +09:00
Tatsuhiro Tsujikawa 018e9eaf6d asio: Clean up server API to explicitly set error code 2015-03-07 01:10:49 +09:00
Tatsuhiro Tsujikawa d6f810d91a examples: Update .gitignore 2015-03-06 03:14:26 +09:00
Tatsuhiro Tsujikawa d8cf29c202 examples: Add less complicated asio client example 2015-03-06 03:13:22 +09:00
Tatsuhiro Tsujikawa a3f79232c6 asio: Use proper cookie syntax 2015-03-06 02:41:07 +09:00
Tatsuhiro Tsujikawa 34ac90443f asio: Rename http2::listen as http2::listen_and_serve 2015-03-06 01:54:28 +09:00
Tatsuhiro Tsujikawa 992c14e354 asio: Rename *_reader as *_generator and read_cb as generator_cb 2015-03-06 01:47:55 +09:00
Tatsuhiro Tsujikawa 42c174e803 asio: Add example to use timer to achieve delayed response 2015-03-06 01:04:46 +09:00
Tatsuhiro Tsujikawa 05b8d8c5b7 asio: Start sending response header when write_head is called 2015-03-06 00:06:53 +09:00
Tatsuhiro Tsujikawa e4ce595ebb asio: Add serve_mux class to route incoming requet by path
serve_mux is direct port of ServeMux from go
2015-03-05 02:12:32 +09:00
Tatsuhiro Tsujikawa 726e6c087d asio: server: Move push member function to response object 2015-03-05 02:12:31 +09:00
Tatsuhiro Tsujikawa e7d052100c asio: Utilize aggregate or value-initialization for header_value 2015-03-05 02:12:31 +09:00
Tatsuhiro Tsujikawa fc2170e488 asio: Use uri_ref in server code 2015-03-05 02:12:31 +09:00
Tatsuhiro Tsujikawa 566baab307 asio: asio-cl: Disable peer verification to make development easier
Don't do this in practice
2015-03-05 02:12:31 +09:00
Tatsuhiro Tsujikawa 6753b6d61e asio: Use header_map in server code 2015-03-05 02:12:31 +09:00
Tatsuhiro Tsujikawa 35817876fe asio: Move server API to asio_http2_server.h 2015-03-05 02:12:31 +09:00
Tatsuhiro Tsujikawa b0c1986a46 asio: Avoid shared_ptr for request and response 2015-03-05 02:12:31 +09:00
Tatsuhiro Tsujikawa 062b42918c asio: Remove threaded task runner
This is too complicated and not suitable for event driven server.  We
plan to expose io_service instead.
2015-03-05 02:12:31 +09:00
Tatsuhiro Tsujikawa 2fa28e790d asio: Separate client API to asio_http2_client.h 2015-03-05 02:12:31 +09:00
Tatsuhiro Tsujikawa 76eab3faa0 asio: Pass connected address to connect_cb 2015-03-05 02:12:31 +09:00
Tatsuhiro Tsujikawa 70ea774f23 asio: Clear up TLS peer verification 2015-03-05 02:12:31 +09:00
Tatsuhiro Tsujikawa e15d302985 asio: Introduce uri_ref 2015-03-05 02:12:31 +09:00
Tatsuhiro Tsujikawa b2196f215a asio: Use boost::system::error_code for on_error callback 2015-03-05 02:12:31 +09:00
Tatsuhiro Tsujikawa 8afd75ca47 Make request, response const 2015-03-05 02:12:31 +09:00
Tatsuhiro Tsujikawa 0676535caf Do async-resove in ctor 2015-03-05 02:12:31 +09:00
Tatsuhiro Tsujikawa dd741a58ae Use header_map instead of wrapping it 2015-03-05 02:12:31 +09:00
Tatsuhiro Tsujikawa 26304546c4 [WIP] Add asio client interface 2015-03-05 02:12:31 +09:00
Tatsuhiro Tsujikawa 3144f7de72 asio-sv2: Fix compile error with OS X
Use struct stat.st_mtime instead of st_mtim which seems to be Linux
specific.
2015-02-21 21:02:40 +09:00
Tatsuhiro Tsujikawa fe84ec5e8b tiny-nghttpd: Add token lookup for slight optimization 2015-02-20 21:50:02 +09:00
Tatsuhiro Tsujikawa 2216fd2bc1 tiny-nghttpd: Remove validations offered by lib 2015-02-20 20:58:11 +09:00
Tatsuhiro Tsujikawa 2dd6353e24 examples/client: Send SETTINGS 2015-02-06 01:22:29 +09:00
Tatsuhiro Tsujikawa fbd9bcb00e Use _LDADD to specify libraries instead of _LDFLAGS
This is because _LDFLAGS comes before _LDADD.  If we specify a library
and another library in _LDADD depends on it, we get undefined
reference error.
2015-01-25 00:58:30 +09:00
Tatsuhiro Tsujikawa 8bfd900be5 src, examples: Check return value 2015-01-07 00:26:17 +09:00
Alexis La Goutte 27fa4d310a Fix: error pointer target types incompatible in C++ [-Werror=c++-compat] 2014-12-16 17:54:47 +01:00
Tatsuhiro Tsujikawa 7036859823 Do not change user variable CFLAGS in configure.ac 2014-12-01 23:06:11 +09:00
Tatsuhiro Tsujikawa 2b465ee65f libevent-client: Disable SSLv3 2014-11-30 21:09:23 +09:00
Tatsuhiro Tsujikawa b1f807abd1 Reformat lines with clang-format-3.5 2014-11-27 23:56:30 +09:00
Tatsuhiro Tsujikawa 5d59adc52b libevent-server: Disable SSLv3 2014-11-27 21:40:34 +09:00
Tatsuhiro Tsujikawa 770cfcaae9 libevent-server: Enable ECDHE ciphers 2014-11-27 21:38:54 +09:00
Tatsuhiro Tsujikawa dfbc6e6a57 examples: Guard include config.h with HAVE_CONFIG_H 2014-11-27 00:12:42 +09:00
Alexis La Goutte bac44d7ffb Fix -Werror=unused-parameter using _U_ macro 2014-11-25 17:08:09 +01:00
Tatsuhiro Tsujikawa 20ffe2b2a0 tiny-nghttpd: Fix memory leak 2014-11-10 21:20:44 +09:00
Tatsuhiro Tsujikawa 0ef99b90d9 asio-lib: Make request_cb take const ref and use int64_t as http_date arg 2014-10-28 01:01:48 +09:00
Tatsuhiro Tsujikawa 9c1b5e8fb1 Update .gitignore 2014-10-18 18:55:42 +09:00
Tatsuhiro Tsujikawa e570225e97 tiny-nghttpd: Simplify timer event handling 2014-10-14 21:52:30 +09:00
Tatsuhiro Tsujikawa 3931a0b04d Fix bugs found by coverity scan 2014-10-10 22:50:35 +09:00
Tatsuhiro Tsujikawa 6d42b6697b examples: Disable tiny-nghttpd if timerfd_create is not available 2014-10-09 21:18:24 +09:00
Tatsuhiro Tsujikawa b6d0a32d0e tiny-nghttpd: Save number of read(2) calls using file size 2014-09-29 22:37:41 +09:00
Tatsuhiro Tsujikawa 88d7abcc23 libnghttp2_asio: Add request::run_task to execute task in separate thread 2014-09-28 16:25:45 +09:00
Tatsuhiro Tsujikawa 409316018d examples: Fix travis error: unreachable-code 2014-09-28 00:02:13 +09:00
Tatsuhiro Tsujikawa 34413d8d7c examples: Build tiny-nghttpd only when epoll is available 2014-09-27 23:45:57 +09:00
Tatsuhiro Tsujikawa b7ccca4c47 examples: Add tiny-nghttpd
tiny-nghttpd is HTTP/2 server and its purpose is measure the
performance of nghttp2 library code.  Currently it only accepts direct
HTTP/2 connection only.
2014-09-27 23:44:33 +09:00
Tatsuhiro Tsujikawa e887b2516f Remove boost LDFLAGS from examples 2014-09-26 21:42:31 +09:00
Tatsuhiro Tsujikawa fd07f5e142 src: Add utility APIs to asio_http2.h; add asio-sv2 example to serve files 2014-09-24 23:05:13 +09:00
Tatsuhiro Tsujikawa 83728219db Update doc 2014-09-24 00:45:40 +09:00
Tatsuhiro Tsujikawa 5d0bf4cc84 Add C++ library libnghttp2_asio on top of libnghttp2
The libnghttp2_asio library is C++ library built on top of libnghttp2.
Currently, it has server API and easily create HTTP/2 server using
node.js like API calls.  See the example server source code in
examples/asio-sv.cc.  The library depends on Boost::ASIO library.
2014-09-24 00:45:40 +09:00
Tatsuhiro Tsujikawa 5ff73de195 libevent-server: Use nghttp2_option_set_recv_client_preface() 2014-09-13 21:24:45 +09:00
Tatsuhiro Tsujikawa ab5b81bee1 Hide nghttp2_session_callbacks details and provide setter like functions
To make it possible to add new callbacks without bumping so name, we
decided to hide details of nghttp2_session_callbacks.  We provide
setter like functions to set individual callback function.
2014-08-25 21:24:04 +09:00
Tatsuhiro Tsujikawa 455d911f61 src, examples: Call OPENSSL_config() 2014-08-02 10:11:45 +09:00
Tatsuhiro Tsujikawa 8dc47c6750 Fix resource leaks 2014-07-18 00:31:32 +09:00
Tatsuhiro Tsujikawa 39498beffd examples: Fix possible division by zero 2014-07-18 00:09:05 +09:00
Tatsuhiro Tsujikawa 8235bb136b doc: Add HPACK API tutorial 2014-06-29 23:45:49 +09:00
Tatsuhiro Tsujikawa ae74a18624 examples: Fix libevent-server which could not send error reply 2014-06-18 13:11:01 +09:00
Tatsuhiro Tsujikawa 85a43cfa66 examples: Check return value of evbuffer_drain 2014-06-18 13:06:05 +09:00
Tatsuhiro Tsujikawa b78a51da0e Support graceful shutdown using multiple GOAWAY
Add last_stream_id parameter to nghttp2_submit_goaway().  To terminate
connection immediately with application chosen last stream ID,
nghttp2_session_terminate_session2() was added.
2014-06-18 11:35:08 +09:00
Tatsuhiro Tsujikawa 9b174bf5c9 Fix compile error with -Wshorten-64-to-32
The original patch was contributed by Alexis La Goutte
2014-06-11 23:37:16 +09:00
Tatsuhiro Tsujikawa e8de437d5c Return new stream ID from nghttp2_submit_{request, headers, push_promise}
Previously stream ID was assigned just before HEADERS or PUSH_PROMISE
was serialized and nghttp2_submit_{request, headers, push_promise} did
not return stream ID.  The application has to check assigned stream ID
using before_frame_send_callback.  Now it is apparent that priority is
meant to DATA transfer only.  Also application can reorder the
requests if it wants. Therefore we can assign stream ID in
nghttp2_submit_* functions and return stream ID from them.  With this
change, now application does not have to check stream ID using
before_frame_send_callback and its code will be simplified.
2014-05-07 23:24:07 +09:00
Tatsuhiro Tsujikawa 4f027c1562 libnghttp2: Remove dependency to zlib
We inherited gzip compression API from spdylay codebase.  In spdylay,
the cost of having such API is almost free because spdylay requires
zlib for header compression.  nghttp2 no longer uses gzip to header
compression.  zlib dependency exists just for gzip compression API,
which is not an essential.  So we decided to move gzip code to under
src and remove zlib dependency from libnghttp2 itself.  As nghttp2
package, we depend on zlib to compile tools under src.
2014-05-06 23:10:50 +09:00
Tatsuhiro Tsujikawa 9ca63de9e8 examples: Zero clear callbacks 2014-05-01 10:46:08 +09:00
Tatsuhiro Tsujikawa 813c750c12 Merge branch 'clang' of https://github.com/alagoutte/nghttp2 into alagoutte-clang 2014-05-01 10:45:38 +09:00
Alexis La Goutte 66ed7f6a59 Fix build when use Clang
libevent-server.c:552:43: error: missing field 'recv_callback' initializer [-Werror,-Wmissing-field-initializers]
2014-04-30 17:31:33 +02:00
Alexis La Goutte 8ca2f6aa92 Fix build when use Clang
libevent-client.c:355:43: error: missing field 'recv_callback' initializer [-Werror,-Wmissing-field-initializers]
2014-04-30 17:31:29 +02:00
Alexis La Goutte fa2fbe944f Fix GCC build with -Werror
libevent-server.c:691:8: error: C++ style comments are not allowed in ISO C90
2014-04-30 17:09:06 +02:00
Tatsuhiro Tsujikawa 660c536275 Extend namelen and valuelen in nghttp2_nv to size_t 2014-04-30 23:08:34 +09:00
Tatsuhiro Tsujikawa 1b79114d2d Fix compiler warnings 2014-04-30 22:16:21 +09:00
Tatsuhiro Tsujikawa e7ad3633c7 nghttp2_data_source_read_callback: Replace eof with uint32_t *data_flags
Replace int *eof with uint32_t *data_flags so that we can easily
extend functionality if we have to (but we don't do if possible).
2014-04-05 17:59:24 +09:00
Tatsuhiro Tsujikawa c9f90924a9 Add flags parameter to nghttp2_on_header_callback 2014-04-02 02:10:35 +09:00
Tatsuhiro Tsujikawa 24cb90806d Add flags to nghttp2_nv structure
This is preliminary change for upcoming HPACK updates.  The flags are
used to determine the name/value pair is indexable or not.
2014-04-01 23:17:50 +09:00
Tatsuhiro Tsujikawa 60a2c260a5 Define NGHTTP2_CLIENT_CONNECTION_PREFACE macro
NGHTTP2_CLIENT_CONNECTION_PREFACE has the same content with
NGHTTP2_CLIENT_CONNECTION_HEADER, which is now obsoleted by
NGHTTP2_CLIENT_CONNECTION_PREFACE.
2014-03-30 21:02:25 +09:00
Tatsuhiro Tsujikawa ab2dc5967d Replace HTTP/2.0 with HTTP/2 2014-03-30 19:26:37 +09:00
Tatsuhiro Tsujikawa f7162ab702 Implement dependency based priority 2014-03-30 01:24:16 +09:00
Tatsuhiro Tsujikawa 46f5d4b1c4 examples: Check stream_data is null 2014-02-20 21:30:05 +09:00
Tatsuhiro Tsujikawa e186e01933 Replace on_end_headers_callback with on_begin_headers_callback
Previously, there is inconsistency when on_frame_recv_callback
is called between HEADERS/PUSH_PROMISE and the other frames.
For former case, it is called before header block, in latter
case, it is called after whole frame is received. To make it
consistent, we call on_frame_recv_callback for HEADERS/PUSH_PROMISE
after its frame is fully received. Since on_frame_recv_callback
can signal the end of header block, we replaced on_end_headers_callback
with on_begin_headers_callback, which is called when the reception
of the header block is started.
2014-01-29 21:23:13 +09:00
Tatsuhiro Tsujikawa 67d4cb6367 examples: Log disconnected in delete_http2_session_data 2014-01-18 01:17:09 +09:00
Tatsuhiro Tsujikawa 2cc28863e9 examples: Fix crash if port is not in request URI 2014-01-18 01:13:04 +09:00
Tatsuhiro Tsujikawa 0b14319675 doc, examples: Update tutorial and examples 2014-01-18 00:06:24 +09:00
Tatsuhiro Tsujikawa 37d41313d3 examples: Fix build failure with android NDK 2014-01-12 21:43:55 +09:00
Tatsuhiro Tsujikawa a47abdba9b Update .gitignore 2014-01-11 01:05:42 +09:00
Tatsuhiro Tsujikawa 0e9390d5ad Move http-parser to third-party dir and fix `make distcheck` 2014-01-11 00:36:20 +09:00