Lines Matching full:we
4 In this tutorial, we are going to write a single-threaded, event-based
19 We use libevent in this tutorial to handle networking I/O. Please
27 example program, when creating the ``SSL_CTX`` object, we store the
29 allocated buffer. This is safe because we only create one ``SSL_CTX``
37 that OpenSSL >= 1.0.2 is required. We use macro to enable/disable
40 them. We provide the callback for it::
92 identifier. In this tutorial, we advertise the specific HTTP/2
96 OpenSSL implementation, we just assign the pointer to the NPN buffers
97 we filled in earlier. The NPN callback function is set to the
100 In ``alpn_select_proto_cb()``, we use `nghttp2_select_next_protocol()`
108 We use the ``app_context`` structure to store application-wide data::
115 We use the ``http2_session_data`` structure to store session-level
126 We use the ``http2_stream_data`` structure to store stream-level data::
135 A single HTTP/2 session can have multiple streams. To manage them, we
148 We first create a listener object to accept incoming connections.
183 We specify the ``acceptcb`` callback, which is called when a new connection is
196 Here we create the ``http2_session_data`` object. The connection's
197 bufferevent is initialized at the same time. We specify three
249 Here we validate that HTTP/2 is negotiated, and if not, drop
253 ``BEV_EVENT_TIMEOUT`` events, we just simply tear down the connection.
260 completed successfully. After this we are ready to begin communicating
290 Since we are creating a server, we use `nghttp2_session_server_new()`
291 to initialize the nghttp2 session object. We also setup 5 callbacks
312 In the example SETTINGS frame we've set
320 Since bufferevent may buffer more than the first 24 bytes from the client, we
322 this pending data. To process the received data, we call the
346 In this function, we feed all unprocessed but already received data to
350 outgoing frames. To send any pending outgoing frames, we immediately
383 Since we use bufferevent to abstract network I/O, we just write the
385 continues to write all frames queued so far. If we were writing the
387 call in the ``send_callback()``, we'd soon receive an ``EAGAIN`` or
391 when writing to the bufferevent, we have to regulate the amount data
393 achieve this, we check the size of the output buffer and if it reaches
394 more than or equal to ``OUTPUT_WOULDBLOCK_THRESHOLD`` bytes, we stop
408 In this function, we just call ``session_recv()`` to process incoming
430 First we check whether we should drop the connection or not. The
437 Since we are using bufferevent and its deferred callback option, the
439 ``writecb()`` is called. To handle this, we check whether the output
440 buffer is empty or not. If all of these conditions are met, we drop
443 Otherwise, we call ``session_send()`` to process the pending output
444 data. Remember that in ``send_callback()``, we must not write all data to
445 bufferevent to avoid excessive buffering. We continue processing pending data
448 We have already described the nghttp2 callback ``send_callback()``. Let's
471 We are only interested in the HEADERS frame in this function. Since
472 the HEADERS frame has several roles in the HTTP/2 protocol, we check
474 a request HEADERS, we create a ``http2_stream_data`` object to store
475 the stream related data. We associate the created
481 In this example server, we want to serve files relative to the current working
514 We search for the ``:path`` header field among the request headers and
516 example program, we ignore the ``:method`` header field and always
547 First we retrieve the ``http2_stream_data`` object associated with the
550 cannot be served for some reason (e.g. file is not found), we send a
551 404 response using ``error_reply()``. Otherwise, we open
552 the requested file and send its content. We send the header field
576 server, we use it as a file descriptor. We also set the
598 If an error occurs while reading the file, we return
602 that we have finished reading the file.
624 Lastly, we destroy the ``http2_stream_data`` object in this function,
625 since the stream is about to close and we no longer need the object.