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 Evgeny Shvidky <ev...@skyfence.com> on 2012/10/03 11:57:50 UTC

RPC over HTTP

Hi,

I am developing a new module on C.
One of the requirements of my module is to receive and handle RPC over HTTP protocol.
RPC over HTTP opens two HTTP/1.1 requests:
One with request method RPC_IN_DATA to send data to the server, and second one with method RPC_OUT_DATA to send data back to the client. The body consists of raw binary data, and the connections are apparently re-used for several RPCs.
Here's an example of an IN connection header:
    RPC_IN_DATA /rpc/rpcproxy.dll?<exchange>:6002 HTTP/1.1
    Content-Length: 1073741824
    ...
After connections are established client sends on "IN" channel RPC message with 104 bytes.

I use the following apache API's in order to read these client message.
ap_setup_client_block(userReq, REQUEST_CHUNKED_ERROR);
ap_should_client_block(userReq)
ap_get_client_block(userReq, buf, size)

The problem is "ap_should_client_block" function returns "1" (means there is message to read) but "ap_get_client_block" returns error (-1) and nothing read.

How should I read client's data?
Is there any other API for it?

Thanks,
Evgeny

RE: RPC over HTTP

Posted by Evgeny Shvidky <ev...@skyfence.com>.
The first RPC message is 104 bytes length and I pass this size to ap_get_client_block() function.

-----Original Message-----
From: Ben Noordhuis [mailto:info@bnoordhuis.nl] 
Sent: Wednesday, October 03, 2012 2:49 PM
To: modules-dev@httpd.apache.org
Subject: Re: RPC over HTTP

On Wed, Oct 3, 2012 at 2:06 PM, Evgeny Shvidky <ev...@skyfence.com> wrote:
> Hi,
>
> ap_setup_client_block() returns OK.
>
> I think the problem is that "Content-Length" header value is 1073741824 (1 GB) and probably apache tries to receive the whole content before it passed to my module.
> Am I right?
> If yes, is there any way to tell apache to send all received data till now?

ap_get_client_block() tries to read up to the number of bytes you requested. Now, if you passed in the value of the Content-Length header, then it will either stall for a long time or simply fail.



Re: RPC over HTTP

Posted by Ben Noordhuis <in...@bnoordhuis.nl>.
On Wed, Oct 3, 2012 at 2:06 PM, Evgeny Shvidky <ev...@skyfence.com> wrote:
> Hi,
>
> ap_setup_client_block() returns OK.
>
> I think the problem is that "Content-Length" header value is 1073741824 (1 GB) and probably apache tries to receive the whole content before it passed to my module.
> Am I right?
> If yes, is there any way to tell apache to send all received data till now?

ap_get_client_block() tries to read up to the number of bytes you
requested. Now, if you passed in the value of the Content-Length
header, then it will either stall for a long time or simply fail.

RE: RPC over HTTP

Posted by Evgeny Shvidky <ev...@skyfence.com>.
Hi,

ap_setup_client_block() returns OK.

I think the problem is that "Content-Length" header value is 1073741824 (1 GB) and probably apache tries to receive the whole content before it passed to my module.
Am I right?
If yes, is there any way to tell apache to send all received data till now?

Thanks,
Evgeny

-----Original Message-----
From: Ben Noordhuis [mailto:info@bnoordhuis.nl] 
Sent: Wednesday, October 03, 2012 1:26 PM
To: modules-dev@httpd.apache.org
Subject: Re: RPC over HTTP

On Wed, Oct 3, 2012 at 11:57 AM, Evgeny Shvidky <ev...@skyfence.com> wrote:
> Hi,
>
> I am developing a new module on C.
> One of the requirements of my module is to receive and handle RPC over HTTP protocol.
> RPC over HTTP opens two HTTP/1.1 requests:
> One with request method RPC_IN_DATA to send data to the server, and second one with method RPC_OUT_DATA to send data back to the client. The body consists of raw binary data, and the connections are apparently re-used for several RPCs.
> Here's an example of an IN connection header:
>     RPC_IN_DATA /rpc/rpcproxy.dll?<exchange>:6002 HTTP/1.1
>     Content-Length: 1073741824
>     ...
> After connections are established client sends on "IN" channel RPC message with 104 bytes.
>
> I use the following apache API's in order to read these client message.
> ap_setup_client_block(userReq, REQUEST_CHUNKED_ERROR);
> ap_should_client_block(userReq)
> ap_get_client_block(userReq, buf, size)
>
> The problem is "ap_should_client_block" function returns "1" (means there is message to read) but "ap_get_client_block" returns error (-1) and nothing read.

Do you check that  ap_setup_client_block() returns OK?

Does ap_get_client_block() return -1 on the first call? If yes, you may want to step through the function in a debugger to see what the error condition is.

> How should I read client's data?
> Is there any other API for it?

The filter API?



Re: RPC over HTTP

Posted by Ben Noordhuis <in...@bnoordhuis.nl>.
On Wed, Oct 3, 2012 at 11:57 AM, Evgeny Shvidky <ev...@skyfence.com> wrote:
> Hi,
>
> I am developing a new module on C.
> One of the requirements of my module is to receive and handle RPC over HTTP protocol.
> RPC over HTTP opens two HTTP/1.1 requests:
> One with request method RPC_IN_DATA to send data to the server, and second one with method RPC_OUT_DATA to send data back to the client. The body consists of raw binary data, and the connections are apparently re-used for several RPCs.
> Here's an example of an IN connection header:
>     RPC_IN_DATA /rpc/rpcproxy.dll?<exchange>:6002 HTTP/1.1
>     Content-Length: 1073741824
>     ...
> After connections are established client sends on "IN" channel RPC message with 104 bytes.
>
> I use the following apache API's in order to read these client message.
> ap_setup_client_block(userReq, REQUEST_CHUNKED_ERROR);
> ap_should_client_block(userReq)
> ap_get_client_block(userReq, buf, size)
>
> The problem is "ap_should_client_block" function returns "1" (means there is message to read) but "ap_get_client_block" returns error (-1) and nothing read.

Do you check that  ap_setup_client_block() returns OK?

Does ap_get_client_block() return -1 on the first call? If yes, you
may want to step through the function in a debugger to see what the
error condition is.

> How should I read client's data?
> Is there any other API for it?

The filter API?