Browse Source

[core] h2.[ch] with stub funcs (incomplete)

(subsequently incrementally updated using git rebase)

huge props and many thank yous to writers of testing tools used while
developing HTTP/2 support in lighttpd:

  h2spec - conformance testing tool for HTTP/2 implementation
           https://github.com/summerwind/h2spec
  h2load - HTTP/2 benchmarking tool
           https://nghttp2.org/documentation/h2load-howto.html
  curl   - command line tool and library for transferring data with URLs
           https://curl.haxx.se/
master
Glenn Strauss 10 months ago
parent
commit
6eca864c5e
  1. 1
      src/CMakeLists.txt
  2. 4
      src/Makefile.am
  3. 2
      src/SConscript
  4. 1
      src/base.h
  5. 3
      src/base_decls.h
  6. 1790
      src/h2.c
  7. 109
      src/h2.h
  8. 3
      src/meson.build
  9. 4
      src/request.h

1
src/CMakeLists.txt

@ -762,6 +762,7 @@ add_executable(lighttpd
server.c
response.c
connections.c
h2.c
reqpool.c
inet_ntop_cache.c
network.c

4
src/Makefile.am

@ -97,7 +97,7 @@ common_src=base64.c buffer.c burl.c log.c \
splaytree.c \
safe_memclear.c
src = server.c response.c connections.c reqpool.c \
src = server.c response.c connections.c h2.c reqpool.c \
inet_ntop_cache.c \
network.c \
network_write.c \
@ -450,7 +450,7 @@ mod_wstunnel_la_LIBADD = $(common_libadd) $(CRYPTO_LIB)
hdr = base64.h buffer.h burl.h network.h log.h http_kv.h keyvalue.h \
response.h request.h reqpool.h fastcgi.h chunk.h \
response.h request.h reqpool.h fastcgi.h chunk.h h2.h \
first.h http_chunk.h \
algo_sha1.h md5.h http_auth.h http_header.h http_vhostdb.h stream.h \
fdevent.h gw_backend.h connections.h base.h base_decls.h stat_cache.h \

2
src/SConscript

@ -78,7 +78,7 @@ common_src = Split("base64.c buffer.c burl.c log.c \
safe_memclear.c \
")
src = Split("server.c response.c connections.c reqpool.c \
src = Split("server.c response.c connections.c h2.c reqpool.c \
inet_ntop_cache.c \
network.c \
network_write.c \

1
src/base.h

@ -25,6 +25,7 @@ struct fdevents; /* declaration */
struct connection {
request_st request;
h2con *h2;
int fd; /* the FD for this connection */
int ndx; /* reverse mapping to server->connection[ndx] */

3
src/base_decls.h

@ -9,6 +9,9 @@ typedef struct server server;
struct connection;
typedef struct connection connection;
struct h2con;
typedef struct h2con h2con;
struct plugin;
typedef struct plugin plugin;

1790
src/h2.c
File diff suppressed because it is too large
View File

109
src/h2.h

@ -0,0 +1,109 @@
#ifndef LI_H2_H
#define LI_H2_H
#include "first.h"
/* time_t */
#include <sys/types.h>
#include <sys/time.h>
#if defined(__APPLE__) && defined(__MACH__)
#if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 1050
#include <time.h>
#endif
#endif
#include "base_decls.h"
#include "buffer.h"
struct chunkqueue; /* declaration */
typedef enum {
H2_FTYPE_DATA = 0x00,
H2_FTYPE_HEADERS = 0x01,
H2_FTYPE_PRIORITY = 0x02,
H2_FTYPE_RST_STREAM = 0x03,
H2_FTYPE_SETTINGS = 0x04,
H2_FTYPE_PUSH_PROMISE = 0x05,
H2_FTYPE_PING = 0x06,
H2_FTYPE_GOAWAY = 0x07,
H2_FTYPE_WINDOW_UPDATE = 0x08,
H2_FTYPE_CONTINUATION = 0x09
} request_h2ftype_t;
typedef enum {
H2_SETTINGS_HEADER_TABLE_SIZE = 0x01,
H2_SETTINGS_ENABLE_PUSH = 0x02,
H2_SETTINGS_MAX_CONCURRENT_STREAMS = 0x03,
H2_SETTINGS_INITIAL_WINDOW_SIZE = 0x04,
H2_SETTINGS_MAX_FRAME_SIZE = 0x05,
H2_SETTINGS_MAX_HEADER_LIST_SIZE = 0x06
} request_h2settings_t;
typedef enum {
H2_FLAG_END_STREAM = 0x01, /* DATA HEADERS */
H2_FLAG_END_HEADERS = 0x04, /* HEADERS PUSH_PROMISE CONTINUATION */
H2_FLAG_PADDED = 0x08, /* DATA HEADERS PUSH_PROMISE */
H2_FLAG_PRIORITY = 0x20, /* HEADERS */
H2_FLAG_ACK = 0x01 /* PING SETTINGS*/
} request_h2flag_t;
typedef enum {
H2_E_NO_ERROR = 0x00,
H2_E_PROTOCOL_ERROR = 0x01,
H2_E_INTERNAL_ERROR = 0x02,
H2_E_FLOW_CONTROL_ERROR = 0x03,
H2_E_SETTINGS_TIMEOUT = 0x04,
H2_E_STREAM_CLOSED = 0x05,
H2_E_FRAME_SIZE_ERROR = 0x06,
H2_E_REFUSED_STREAM = 0x07,
H2_E_CANCEL = 0x08,
H2_E_COMPRESSION_ERROR = 0x09,
H2_E_CONNECT_ERROR = 0x0a,
H2_E_ENHANCE_YOUR_CALM = 0x0b,
H2_E_INADEQUATE_SECURITY = 0x0c,
H2_E_HTTP_1_1_REQUIRED = 0x0d
} request_h2error_t;
typedef enum {
H2_STATE_IDLE,
H2_STATE_RESERVED_LOCAL,
H2_STATE_RESERVED_REMOTE,
H2_STATE_OPEN,
H2_STATE_HALF_CLOSED_LOCAL,
H2_STATE_HALF_CLOSED_REMOTE,
H2_STATE_CLOSED
} request_h2state_t;
struct h2con {
request_st *r[8];
uint32_t rused;
uint32_t h2_cid;
uint32_t h2_sid;
int32_t sent_goaway;
time_t sent_settings;
uint32_t s_header_table_size; /* SETTINGS_HEADER_TABLE_SIZE */
uint32_t s_enable_push; /* SETTINGS_ENABLE_PUSH */
uint32_t s_max_concurrent_streams; /* SETTINGS_MAX_CONCURRENT_STREAMS */
int32_t s_initial_window_size; /* SETTINGS_INITIAL_WINDOW_SIZE */
uint32_t s_max_frame_size; /* SETTINGS_MAX_FRAME_SIZE */
uint32_t s_max_header_list_size; /* SETTINGS_MAX_HEADER_LIST_SIZE */
};
void h2_send_goaway (connection *con, request_h2error_t e);
int h2_parse_frames (connection *con);
int h2_want_read (connection *con);
void h2_init_con (request_st * restrict h2r, connection * restrict con, const buffer * restrict http2_settings);
void h2_send_100_continue (request_st *r, connection *con);
void h2_send_cqheaders (request_st *r, connection *con);
void h2_send_cqdata (request_st *r, connection *con, struct chunkqueue *cq, uint32_t dlen);
void h2_send_end_stream (request_st *r, connection *con);
#endif

3
src/meson.build

@ -685,10 +685,11 @@ main_src = [
'configfile.c',
'connections.c',
'data_config.c',
'reqpool.c',
'h2.c',
'inet_ntop_cache.c',
'network_write.c',
'network.c',
'reqpool.c',
'response.c',
'server.c',
]

4
src/request.h

@ -122,6 +122,10 @@ typedef enum {
struct request_st {
request_state_t state; /*(modules should not modify request state)*/
int http_status;
uint32_t h2state; /*(modules should not modify request h2state)*/
uint32_t h2id;
int32_t h2_rwin;
int32_t h2_swin;
http_method_t http_method;
http_version_t http_version;

Loading…
Cancel
Save