[ 
https://issues.apache.org/jira/browse/HTTPCORE-73?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Steffen Pingel updated HTTPCORE-73:
-----------------------------------

    Description: 
Add a new method to NHttpServiceHandler that notifies the service handler that 
a response has been sent: 

void responseSubmitted(NHttpServerConnection conn); 

The sent response can be retrieved through conn.getHttpResponse() when the 
method is invoked. The use case here is that I need to enable and disable 
throttling per response (which is handled by the underlying NIO layer) and need 
to know at what point the output buffer for a response has been flushed. The 
throttling is controlled in the application layer so I need to propagate the 
event through the layers. 

Such an event notification could also replace 
NHttpServerConnection.isResponseSubmitted() which currently has an 
implementation in DefaultNHttpServerConnection that does not match the JavaDoc 
specification.

  was:
Add a new method to NHttpServiceHandler that notifies the service handler that 
a response has been sent:

 void responseSubmitted(NHttpServerConnection conn);

The sent response can be retrieved through conn.getHttpResponse() when the 
method is invoked. The use case here is that I need to enable and disable 
throttling per response (which is handled by the underlying NIO layer) and need 
to know at what point the output buffer for a response has been flushed. The 
throttling is controlled in the application layer so I need to propagate the 
event through the layers.

Such an event notification could also replace 
NHttpServerConnection.isResponseSubmitted() which currently has an 
implementation in DefaultNHttpServerConnection that does not match the JavaDoc 
specification.





> (1) response head has been submitted and copied to the session buffer

I think that is internal to the implementation of the connection (and the case 
when DefaultNHttpServerConnection.submitResponse() returns), so I don't think 
an event is needed here.

My current approach fires the event when the encoder has completed and the 
session buffer in DefaultNHttpServerConnection has been written to the channel. 

> (2) response head has been written from the session buffer to the underlying
> channel

An explicit event would be nice but I currently assume that when 
NHttpServiceHandler.outputReady() is invoked that the head has been written and 
the body is now being processed. 

For HEAD requests an event is fired since NHttpServiceHandler.outputReady() is 
not invoked.

> (3) response head and response body have been fully written to the underlying
> channel

An event is fired here (in order to switch throttling and to update the UI).

> PS: My guts tell me this one is going to be ugly

In order to get it working cleanly I modified DefaultNHttpServerConnection to 
process responses sequentially. I have to agree that it would get ugly when it 
came to keeping track which part of the session buffer maps to which response 
to fire events accordingly.


> Add notification to NHttpServiceHandler when response has been sent
> -------------------------------------------------------------------
>
>                 Key: HTTPCORE-73
>                 URL: https://issues.apache.org/jira/browse/HTTPCORE-73
>             Project: HttpComponents Core
>          Issue Type: Improvement
>          Components: HttpCore NIO
>    Affects Versions: 4.0-alpha5
>            Reporter: Steffen Pingel
>
> Add a new method to NHttpServiceHandler that notifies the service handler 
> that a response has been sent: 
> void responseSubmitted(NHttpServerConnection conn); 
> The sent response can be retrieved through conn.getHttpResponse() when the 
> method is invoked. The use case here is that I need to enable and disable 
> throttling per response (which is handled by the underlying NIO layer) and 
> need to know at what point the output buffer for a response has been flushed. 
> The throttling is controlled in the application layer so I need to propagate 
> the event through the layers. 
> Such an event notification could also replace 
> NHttpServerConnection.isResponseSubmitted() which currently has an 
> implementation in DefaultNHttpServerConnection that does not match the 
> JavaDoc specification.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to