コード例 #1
0
ファイル: http1.c プロジェクト: dstufft/h2o
void h2o_http1_accept(h2o_accept_ctx_t *ctx, h2o_socket_t *sock, struct timeval connected_at)
{
    static const h2o_conn_callbacks_t callbacks = {
        get_sockname, /* stringify address */
        get_peername, /* ditto */
        NULL,         /* push */
        {{
          {log_protocol_version, log_session_reused, log_cipher, log_cipher_bits}, /* ssl */
          {log_request_index},                                                     /* http1 */
          {}                                                                       /* http2 */
        }}};
    struct st_h2o_http1_conn_t *conn = (void *)h2o_create_connection(sizeof(*conn), ctx->ctx, ctx->hosts, connected_at, &callbacks);

    /* zero-fill all properties expect req */
    memset((char *)conn + sizeof(conn->super), 0, offsetof(struct st_h2o_http1_conn_t, req) - sizeof(conn->super));

    /* init properties that need to be non-zero */
    conn->super.ctx = ctx->ctx;
    conn->super.hosts = ctx->hosts;
    conn->super.connected_at = connected_at;
    conn->super.callbacks = &callbacks;
    conn->sock = sock;
    sock->data = conn;
    h2o_linklist_insert(&ctx->ctx->http1._conns, &conn->_conns);

    init_request(conn, 0);
    reqread_start(conn);
}
コード例 #2
0
ファイル: http1.c プロジェクト: ifzz/h2o
void h2o_http1_accept(h2o_accept_ctx_t *ctx, h2o_socket_t *sock, struct timeval connected_at)
{
    static const h2o_conn_callbacks_t callbacks = {get_sockname, get_peername};
    struct st_h2o_http1_conn_t *conn = h2o_mem_alloc(sizeof(*conn));

    /* zero-fill all properties expect req */
    memset(conn, 0, offsetof(struct st_h2o_http1_conn_t, req));

    /* init properties that need to be non-zero */
    conn->super.ctx = ctx->ctx;
    conn->super.hosts = ctx->hosts;
    conn->super.connected_at = connected_at;
    conn->super.callbacks = &callbacks;
    conn->sock = sock;
    sock->data = conn;

    init_request(conn, 0);
    reqread_start(conn);
}
コード例 #3
0
ファイル: http1.c プロジェクト: 4Second2None/h2o
static void on_send_complete(h2o_socket_t *sock, int status)
{
    struct st_h2o_http1_conn_t *conn = sock->data;

    assert(conn->req._ostr_top == &conn->_ostr_final.super);

    if (!conn->req.http1_is_persistent) {
        /* TODO use lingering close */
        close_connection(conn);
        return;
    }

    /* handle next request */
    init_request(conn, 1);
    h2o_buffer_consume(&conn->sock->input, conn->_reqsize);
    conn->_prevreqlen = 0;
    conn->_reqsize = 0;
    reqread_start(conn);
}
コード例 #4
0
ファイル: http1.c プロジェクト: laysakura/h2o
void h2o_http1_accept(h2o_context_t *ctx, h2o_socket_t *sock)
{
    h2o_http1_conn_t *conn = h2o_mem_alloc(sizeof(*conn));

    /* zero-fill all properties expect req */
    memset(conn, 0, offsetof(h2o_http1_conn_t, req));

    /* init properties that need to be non-zero */
    conn->super.ctx = ctx;
    if (sock->peername.len != 0) {
        conn->super.peername.addr = (void*)&sock->peername.addr;
        conn->super.peername.len = sock->peername.len;
    }
    conn->sock = sock;
    sock->data = conn;

    init_request(conn, 0);
    reqread_start(conn);
}