Csilk 0.2.1
A lightweight, high-performance C HTTP web framework
Loading...
Searching...
No Matches
h2.c File Reference

HTTP/2 integration for csilk. More...

#include "h2.h"
#include "csilk/csilk.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
Include dependency graph for h2.c:

Functions

static int on_begin_headers_callback (nghttp2_session *session, const nghttp2_frame *frame, void *user_data)
 
static int on_header_callback (nghttp2_session *session, const nghttp2_frame *frame, const uint8_t *name, size_t namelen, const uint8_t *value, size_t valuelen, uint8_t flags, void *user_data)
 
static int on_frame_recv_callback (nghttp2_session *session, const nghttp2_frame *frame, void *user_data)
 
static int on_data_chunk_recv_callback (nghttp2_session *session, uint8_t flags, int32_t stream_id, const uint8_t *data, size_t len, void *user_data)
 
static int on_stream_close_callback (nghttp2_session *session, int32_t stream_id, uint32_t error_code, void *user_data)
 
static ssize_t send_callback (nghttp2_session *session, const uint8_t *data, size_t length, int flags, void *user_data)
 
csilk_ctx_t * csilk_h2_get_or_create_stream (csilk_client_t *client, int32_t stream_id)
 Get an existing stream context or create a new one.
 
void csilk_h2_free_streams (csilk_client_t *client)
 Free all active HTTP/2 stream contexts for a client.
 
int csilk_h2_init_session (csilk_client_t *client)
 Initialize HTTP/2 session for a client connection.
 
int csilk_h2_process_data (csilk_client_t *client, const uint8_t *data, size_t len)
 Process incoming HTTP/2 data.
 

Detailed Description

HTTP/2 integration for csilk.

Function Documentation

◆ csilk_h2_free_streams()

void csilk_h2_free_streams ( csilk_client_t *  client)

Free all active HTTP/2 stream contexts for a client.

Parameters
clientThe client connection.

◆ csilk_h2_get_or_create_stream()

csilk_ctx_t * csilk_h2_get_or_create_stream ( csilk_client_t *  client,
int32_t  stream_id 
)

Get an existing stream context or create a new one.

Parameters
clientThe client connection.
stream_idThe HTTP/2 stream ID.
Returns
Pointer to the context, or NULL on failure.

◆ csilk_h2_init_session()

int csilk_h2_init_session ( csilk_client_t *  client)

Initialize HTTP/2 session for a client connection.

Parameters
clientThe client connection.
Returns
0 on success, < 0 on failure.

◆ csilk_h2_process_data()

int csilk_h2_process_data ( csilk_client_t *  client,
const uint8_t *  data,
size_t  len 
)

Process incoming HTTP/2 data.

Parameters
clientThe client connection.
dataThe incoming data buffer.
lenThe length of the incoming data.
Returns
0 on success, < 0 on failure.

◆ on_begin_headers_callback()

static int on_begin_headers_callback ( nghttp2_session *  session,
const nghttp2_frame *  frame,
void *  user_data 
)
static

◆ on_data_chunk_recv_callback()

static int on_data_chunk_recv_callback ( nghttp2_session *  session,
uint8_t  flags,
int32_t  stream_id,
const uint8_t *  data,
size_t  len,
void *  user_data 
)
static

◆ on_frame_recv_callback()

static int on_frame_recv_callback ( nghttp2_session *  session,
const nghttp2_frame *  frame,
void *  user_data 
)
static

◆ on_header_callback()

static int on_header_callback ( nghttp2_session *  session,
const nghttp2_frame *  frame,
const uint8_t *  name,
size_t  namelen,
const uint8_t *  value,
size_t  valuelen,
uint8_t  flags,
void *  user_data 
)
static

◆ on_stream_close_callback()

static int on_stream_close_callback ( nghttp2_session *  session,
int32_t  stream_id,
uint32_t  error_code,
void *  user_data 
)
static

◆ send_callback()

static ssize_t send_callback ( nghttp2_session *  session,
const uint8_t *  data,
size_t  length,
int  flags,
void *  user_data 
)
static