msh3: add support for QUIC and HTTP/3 using msh3

Considered experimental, as the other HTTP/3 backends.

Closes #8517
This commit is contained in:
Nick Banks 2022-04-10 18:21:37 +02:00 committed by Daniel Stenberg
parent 7befbe9ce9
commit 37492ebbfa
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
18 changed files with 850 additions and 7 deletions

View file

@ -38,6 +38,10 @@ typedef enum {
#include <nghttp2/nghttp2.h>
#endif
#if defined(_WIN32) && defined(ENABLE_QUIC)
#include <stdint.h>
#endif
extern const struct Curl_handler Curl_handler_http;
#ifdef USE_SSL
@ -163,6 +167,29 @@ CURLcode Curl_http_auth_act(struct Curl_easy *data);
struct h3out; /* see ngtcp2 */
#endif
#ifdef USE_MSH3
#ifdef _WIN32
#define msh3_lock CRITICAL_SECTION
#define msh3_lock_initialize(lock) InitializeCriticalSection(lock)
#define msh3_lock_uninitialize(lock) DeleteCriticalSection(lock)
#define msh3_lock_acquire(lock) EnterCriticalSection(lock)
#define msh3_lock_release(lock) LeaveCriticalSection(lock)
#else /* !_WIN32 */
#include <pthread.h>
#define msh3_lock pthread_mutex_t
#define msh3_lock_initialize(lock) { \
pthread_mutexattr_t attr; \
pthread_mutexattr_init(&attr); \
pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE); \
pthread_mutex_init(lock, &attr); \
pthread_mutexattr_destroy(&attr); \
}
#define msh3_lock_uninitialize(lock) pthread_mutex_destroy(lock)
#define msh3_lock_acquire(lock) pthread_mutex_lock(lock)
#define msh3_lock_release(lock) pthread_mutex_unlock(lock)
#endif /* _WIN32 */
#endif /* USE_MSH3 */
/****************************************************************************
* HTTP unique setup
***************************************************************************/
@ -228,11 +255,13 @@ struct HTTP {
#endif
#ifdef ENABLE_QUIC
#ifndef USE_MSH3
/*********** for HTTP/3 we store stream-local data here *************/
int64_t stream3_id; /* stream we are interested in */
bool firstheader; /* FALSE until headers arrive */
bool firstbody; /* FALSE until body arrives */
bool h3req; /* FALSE until request is issued */
#endif
bool upload_done;
#endif
#ifdef USE_NGHTTP3
@ -240,6 +269,21 @@ struct HTTP {
struct h3out *h3out; /* per-stream buffers for upload */
struct dynbuf overflow; /* excess data received during a single Curl_read */
#endif
#ifdef USE_MSH3
struct MSH3_REQUEST *req;
msh3_lock recv_lock;
/* Receive Buffer (Headers and Data) */
uint8_t* recv_buf;
size_t recv_buf_alloc;
/* Receive Headers */
size_t recv_header_len;
bool recv_header_complete;
/* Receive Data */
size_t recv_data_len;
bool recv_data_complete;
/* General Receive Error */
CURLcode recv_error;
#endif
};
#ifdef USE_NGHTTP2