A few quests

"이희승 (Trustin Lee)" trustin at gmail.com
Wed Jul 7 03:04:27 EDT 2010


Hi Brendt,

On 07/06/2010 05:49 PM, Brendt wrote:
> 
> Hi,
> 
> I'm trying to use netty to develope a HTTP proxy based application.  I have
> a few questions that I hope you will be able to answer.
> 
> Question One:
> 
> My proxy server forwards HTTP Requests for HTML files to Server A and images
> (jpg, png, etc.) to Server B.
> 
> For public void messageReceived(ChannelHandlerContext ctx, MessageEvent e)
> method of SimpleChannelUpstreamHandler would e.getChannel() return the same
> channel object for two separate HttpRequest objects from the same client?
> (e.g. http://www.mysite.com/index.html and
> http://www.mysite.com/images/myimage.jpg)  
> 
> The reason I ask this is... I store a reference to the proxy-to-backend
> channel based on the client-to-proxy channel.  If the relationship exists in
> my store, then I do not need to create a clientboostrap and call connect().
> 
> So you can see that if the first request is an HTML file, my proxy server
> will create a proxy-to-backend channel to Server A and store the
> relationship between the two.  So if the second request is for a JPG and the
> same client-to-proxy channel is used, I will find an existing relationship
> and send the JPG request to Server A (which I obviously don't want to do).

If the two requests were sent from the same connection, e.getChannel()
will point the same channel.  However, in HTTP, you cannot ensure that
because it highly depends on the client implementation and HTTP doesn't
enforce anything like that.

> Question Two:
> 
> As I've mentioned my proxy creates connections to multiple backend servers. 
> I have a ProxyResponseHandler (handles responses from the backend server and
> relays them back to the client).  In it's messsageReceived() method, after
> writing the entire Http Response back to the client, should I be closing any
> of the channels manually, or should I rely on the backend server notifying
> netty of a channel closure?

I think it's up to you.  You can always keep the connection in the
background to reuse/pool it.

HTH,
Trustin

-- 
what we call human nature in actuality is human habit
http://gleamynode.net/

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 293 bytes
Desc: OpenPGP digital signature
Url : http://lists.jboss.org/pipermail/netty-users/attachments/20100707/c37a2673/attachment.bin 


More information about the netty-users mailing list