I need re-usable async http parsing code. Does netty perhaps contain some api for just the parsing portion? (I always have a belief that parsers should be separate and re-usable and not tied to the framework so I hope netty’s is reusable as well).
ie. It would be great to feed in bytes like so and it returns null if
there is not yet enough bytes
private byte[] previousData;
byte[] data = incomingMergedWithPrevious(previousData);
HttpResponse resp = httpResponseParser.parse(data);
if(resp == null) {
return; //we do not have full data to parse yet
}
//otherwise fire the response to someone else.
OR maybe I could re-use the code a different way. All I know is I get
bytes that don’t always have all the http headers yet since it is
asynch stuff. Any way to parse stuff?
NOTE: Also, I want to do chunking so I am not sure it should return HttpResponse every time but maybe an List where one subclass is HttpHeaders and another is HttpChunk.
thanks,
Dean
You can use the DecoderEmbedder probably in conjunction with HttpMessageDecoder. There’s an example on the DecoderEmbedder page. It sounds like you want to use the pollAll method. You’ll need to check the type of each returned object if you want to process HttpResponse and HttpChunk messages differently.