You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modules-dev@httpd.apache.org by Marco Spinetti <m....@pisa.iol.it> on 2008/02/25 11:58:27 UTC

Write to client directly

I'd like to know if it's possibile to write directly to the client.
Actually in my module handler (apache 2.2) I have:

ap_set_content_type(r, "text/html");
ap_rwrite(bufptr, size, r);
ap_rflush(r);
....

where bufptr is obtained by libxslt xsltSaveResultToString.
Because it's possibile to write the output of the transform to stdout 
directly, I'd like to know if I could delete the bufptr creation.
The libxml2 function to write to stdout is:

xsltSaveResultToFile(stdout, ....);

So could I write in my module something like this below?
ap_set_content_type(r, "text/html");
xsltSaveResultToFile(stdout, ....);
.....

Best regards
Marco



Re: Write to client directly

Posted by Jarek Kucypera <ja...@netstellar.com>.
> What do you mean?
>
> Jarek Kucypera ha scritto:
>> ... force connection close ...
>>
>
I just corrected misspelled fragment.

J.K.

Re: Write to client directly

Posted by Marco Spinetti <m....@pisa.iol.it>.
What do you mean?

Jarek Kucypera ha scritto:
> ... force connection close ...
>


Re: Write to client directly

Posted by Jarek Kucypera <ja...@netstellar.com>.
... force connection close ...

Re: Write to client directly

Posted by Jarek Kucypera <ja...@netstellar.com>.
Użytkownik Marco Spinetti napisał:
> Has anyone some ideas?

I don't think it's possible. But if you're already plaing with it, try 
first to flush output before writing
to the socket, this should push the headers out.
Also have in mind content length issues , you must either
set content length or force connection, i think (but i'm not a guru).

In general, i don't think omitting the output filter chain is a good idea.

J.K.

Re: Write to client directly

Posted by Marco Spinetti <m....@pisa.iol.it>.
Has anyone some ideas?
I tried  in this way:

static int get_socketclient(request_rec *r)
{
    apr_os_sock_t cl_fd;
    conn_rec *conn = r->connection;
    apr_socket_t *csd = ((core_net_rec 
*)conn->input_filters->ctx)->client_socket;
    apr_os_sock_get(&cl_fd, csd);
    return (int)cl_fd;
}

In my handler:

....
ap_set_content_type(r, "text/html");
xsltSaveResultToFd(get_socketclient(r), res, (tipo_xslt) ? 
sconf->aziende : sconf->web);

The problem is that the output starts with some html code and then I 
have the response headers and then nothing else.....
Some ideas?
Best regards


Marco Spinetti ha scritto:
> I'd like to know if it's possibile to write directly to the client.
> Actually in my module handler (apache 2.2) I have:
>
> ap_set_content_type(r, "text/html");
> ap_rwrite(bufptr, size, r);
> ap_rflush(r);
> ....
>
> where bufptr is obtained by libxslt xsltSaveResultToString.
> Because it's possibile to write the output of the transform to stdout 
> directly, I'd like to know if I could delete the bufptr creation.
> The libxml2 function to write to stdout is:
>
> xsltSaveResultToFile(stdout, ....);
>
> So could I write in my module something like this below?
> ap_set_content_type(r, "text/html");
> xsltSaveResultToFile(stdout, ....);
> .....
>
> Best regards
> Marco
>
>
>