mina-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Marek Sedlak <bodka.zavi...@gmail.com>
Subject Re: HttpServer - messageReceived
Date Thu, 29 Jan 2015 10:17:42 GMT
Hello Emanuel,
thank you for your tips, it seems to be working for me, I am checking the
data manually, little bit customized to our needs,
thanks for the reply!
Regards,
Marek

2015-01-27 19:41 GMT+01:00 Emmanuel Lécharny <elecharny@gmail.com>:

> Le 27/01/15 17:34, Marek Sedlak a écrit :
> > Hello,
> >
> > I have been trying to implement a simple http server. Firstly using
> > TextLineCodecFactory, but it became little useles for parsing binary data
> > comming in request.
> > What I decided to do, is basically TCP server, and reading requests
> > manually. All I need to do is to get byte array data of request.
> >
> > in method messageReceived(Object o) the data come, but sometimes (usually
> > on POST/PATCH requests) the body comes in another call of this method.
> >
> > Then I dont know when the data is complete. Can you please guide me? I am
> > using MINA 2.0.9.
>
> This is typically what happen with TCP fragmentation.
>
> The data may arrive chunk by chunk. You can even imagine receiving them
> one byte by one byte...
>
> So you have to take care of such a fragmentation, which is not exactly
> simple with a protocol like HTTP, where you have no information
> whatsoever about the size of what you are going to receive.
>
> The best possible solution would be to decode what you get, excpecting
> it's not going to be cut in the middle. If you don't have anough data,
> then you have to suspend the decoding, and wait for more data...
>
>
>


-- 
If an experiment works, something has gone wrong :P

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message