Exemplo n.º 1
0
static void
flush_headers(slash_context_t* ctx)
{
    sl_response_key_value_t* headers;
    size_t header_count, i;
    if(!ctx->headers_sent) {
        ctx->r->status = sl_response_get_status(ctx->vm);
        ctx->r->status_line = ap_get_status_line(ctx->r->status);
        headers = sl_response_get_headers(ctx->vm, &header_count);
        for(i = 0; i < header_count; i++) {
            apr_table_add(ctx->r->headers_out, headers[i].name, headers[i].value);
        }
        ctx->headers_sent = 1;
    }
}
Exemplo n.º 2
0
static void
flush_headers(slash_context_t* ctx)
{
#ifdef SL_TEST
    /* don't write the headers in testing mode */
    return;
#endif
    int status;
    sl_response_key_value_t* headers;
    size_t header_count, i;

    if(!ctx->headers_sent) {
        int content_type_sent = 0;
        ctx->headers_sent = 1;

        status = sl_response_get_status(ctx->vm);

        write_status(ctx, status);

        headers = sl_response_get_headers(ctx->vm, &header_count);
        for(i = 0; i < header_count; i++) {
            if(!content_type_sent &&
                strcasecmp("Content-Type", headers[i].name) == 0) {
                content_type_sent = 1;
            }
            write_header(ctx, headers[i].name, headers[i].value);
        }

        if(!content_type_sent) {
            write_header(ctx, "Content-Type", "text/html; charset=utf-8");
        }

        /* terminate headers */
        ctx->api->write_out(ctx->api, SAPI_CGI_HEADER_SEPARATOR,
            SAPI_CGI_HEADER_SEPARATOR_LENGTH);
    }
}
Exemplo n.º 3
0
static void
flush_headers(slash_context_t* ctx)
{
    sl_response_key_value_t* headers;
    size_t header_count, i;
    int sent_content_type = 0;
    if(ctx->sent_headers) {
        return;
    }
    ctx->sent_headers = 1;
    headers = sl_response_get_headers(ctx->vm, &header_count);
    FCGX_FPrintF(ctx->request.out, "Status: %d\r\n", sl_response_get_status(ctx->vm));
    for(i = 0; i < header_count; i++) {
        /* @TODO: do something not non-standard */
        if(strcasecmp(headers[i].name, "Content-Type") == 0) {
            sent_content_type = 1;
        }
        FCGX_FPrintF(ctx->request.out, "%s: %s\r\n", headers[i].name, headers[i].value);
    }
    if(!sent_content_type) {
        FCGX_PutS("Content-Type: text/html; charset=utf-8\r\n", ctx->request.out);
    }
    FCGX_PutS("\r\n", ctx->request.out);
}