コード例 #1
0
ファイル: errormap.c プロジェクト: cristdai/squid2
static void
errorMapFetchHeaders(void *data, mem_node_ref nr, ssize_t size)
{
    ErrorMapState *state = data;
    HttpReply *reply;
    http_status status;

    if (EBIT_TEST(state->e->flags, ENTRY_ABORTED))
	goto abort;
    if (size == 0)
	goto abort;
    if (!cbdataValid(state->callback_data))
	goto abort;

    reply = state->e->mem_obj->reply;

    status = reply->sline.status;
    if (status != HTTP_OK)
	goto abort;
    /* Send object to caller (cbdataValid verified above) */
    state->callback(state->e, reply->hdr_sz, httpHeaderGetSize(&reply->header, HDR_CONTENT_LENGTH), state->callback_data);
    errorMapFetchComplete(state);
    stmemNodeUnref(&nr);
    return;

  abort:
    errorMapFetchAbort(state);
    stmemNodeUnref(&nr);
    return;
}
コード例 #2
0
ファイル: HttpReply.c プロジェクト: carriercomm/myboxfs
/* sync this routine when you update HttpReply struct */
static void
httpReplyHdrCacheInit(HttpReply * rep)
{
    const HttpHeader *hdr = &rep->header;
    const char *str;
    rep->content_length = httpHeaderGetSize(hdr, HDR_CONTENT_LENGTH);
    rep->date = httpHeaderGetTime(hdr, HDR_DATE);
    rep->last_modified = httpHeaderGetTime(hdr, HDR_LAST_MODIFIED);
    str = httpHeaderGetStr(hdr, HDR_CONTENT_TYPE);
    if (str)
	stringLimitInit(&rep->content_type, str, strcspn(str, ";\t "));
    else
	rep->content_type = StringNull;
    rep->cache_control = httpHeaderGetCc(hdr);
    rep->content_range = httpHeaderGetContRange(hdr);
    rep->keep_alive = httpMsgIsPersistent(rep->sline.version, &rep->header);
    /* be sure to set expires after date and cache-control */
    rep->expires = httpReplyHdrExpirationTime(rep);
}