mitre / HTTP-Proxy-Servlet

Smiley's HTTP Proxy implemented as a Java servlet
Apache License 2.0
1.46k stars 555 forks source link

Stream incorrectly closed #1

Open krokodylowy opened 12 years ago

krokodylowy commented 12 years ago

Hi

In method copyResponseEntity you close stream with closeQuietly before is flushed to service output !?

I must remove this line to see xml service response.

dsmiley commented 12 years ago

So you're basically saying there should be one more line: servletOutputStream.flush() before the finally block? Just curious, what servlet engine did you see the problem in? I've in general considered close() to implicitly flush buffered content. I'd like to be able to reproduce the error you found if possible.

Wether close() needs to be called at all is ambiguous in the spec; it appears the web container is supposed to take care of it but it seems to be harmless if you do it yourself. I'm tempted to omit the close() from that method and either do a flush, then close, just flush, or neither after copyResponseEntity() is called, but I'd like to test.

krokodylowy commented 12 years ago

Not before. You don't handle errors and close stream to early. The same problem was with edwards version.

My code use these changes: at line 172 add servletResponse.flush() at line 273 remove closeQuietly()

My environment Tomcat 6.0.30/jdk 1.6/servlet 1.5 and jboss webservices.