Пример #1
0
PUBLIC HTStream * HTNewsPost_new (HTRequest * request, HTStream * target)
{
    HTStream * me;
    if ((me = (HTStream  *) HT_CALLOC(1, sizeof(HTStream))) == NULL)
        HT_OUTOFMEM("NewsPost_new");
    me->isa = &NewsPostClass;
    me->target = target;
    me->request = request;
    me->buffer = HTChunk_new(256);
    me->transparent = NO;
    return HTMIMERequest_new(request, me, YES);
}
Пример #2
0
/*
**	This is our handle to the server reply stream when data is coming
**	back from our "client" request. It is responsible for setting up the
**	remaining streams in order to produce a complete HTTP output.
**	If we have a HTTP 1.x response then forward untouched.
*/
PRIVATE int MakeReplyPipe (HTStream * me, HTRequest * client)
{
    char * response_line = NULL;

    /* Generate the Response line */
    {
        HTAlertCallback *cbf = HTAlert_find(HT_A_MESSAGE);
        if (cbf) {
            HTAlertPar * reply = HTAlert_newReply();
            if ((*cbf)(client, HT_A_MESSAGE, HT_MSG_NULL, NULL,
                       HTRequest_error(client), reply))
                response_line = HTAlert_replyMessage(reply);
            HTAlert_deleteReply(reply);
        }

        if (response_line) {
            PUTS(response_line);
            HT_FREE(response_line);
        } else {
            PUTS(HTTP_VERSION);
            PUTS(" 500 Internal");
            PUTC(CR);
            PUTC(LF);
        }
    }

    /*
    ** We now have to create the rest of the response stream. We see whether
    ** there is a data object or not by looking at the Content Type of the
    ** client anchor.
    */
    {
        HTParentAnchor * anchor = HTRequest_anchor(client);
        HTFormat format = HTAnchor_format(anchor);
        me->target = (format == WWW_UNKNOWN) ?
                     HTTPResponse_new(client, me->target, YES, HTTP_11) :
                     HTMIMERequest_new(client,
                                       HTTPResponse_new(client,me->target, NO, HTTP_11), YES);
    }
    return HT_OK;
}