comparison src/org/eclipse/jetty/server/AbstractHttpConnection.java @ 982:dbecd7faa1f5

remove Generator
author Franklin Schmidt <fschmidt@gmail.com>
date Sun, 16 Oct 2016 21:40:27 -0600
parents f46de416e219
children 23ec25435b8c
comparison
equal deleted inserted replaced
981:f46de416e219 982:dbecd7faa1f5
28 import javax.servlet.ServletOutputStream; 28 import javax.servlet.ServletOutputStream;
29 import javax.servlet.http.HttpServletRequest; 29 import javax.servlet.http.HttpServletRequest;
30 import javax.servlet.http.HttpServletResponse; 30 import javax.servlet.http.HttpServletResponse;
31 31
32 import org.eclipse.jetty.http.EncodedHttpURI; 32 import org.eclipse.jetty.http.EncodedHttpURI;
33 import org.eclipse.jetty.http.Generator;
34 import org.eclipse.jetty.http.HttpBuffers; 33 import org.eclipse.jetty.http.HttpBuffers;
35 import org.eclipse.jetty.http.HttpException; 34 import org.eclipse.jetty.http.HttpException;
36 import org.eclipse.jetty.http.HttpFields; 35 import org.eclipse.jetty.http.HttpFields;
37 import org.eclipse.jetty.http.HttpGenerator; 36 import org.eclipse.jetty.http.HttpGenerator;
38 import org.eclipse.jetty.http.HttpHeaderValues; 37 import org.eclipse.jetty.http.HttpHeaderValues;
86 * (HttpParser)http.getParser()).getHeaderBuffer() and 85 * (HttpParser)http.getParser()).getHeaderBuffer() and
87 * (HttpParser)http.getParser()).getBodyBuffer() to initialise their new connection. 86 * (HttpParser)http.getParser()).getBodyBuffer() to initialise their new connection.
88 * </p> 87 * </p>
89 * 88 *
90 */ 89 */
91 public abstract class AbstractHttpConnection extends AbstractConnection 90 public abstract class AbstractHttpConnection extends AbstractConnection
92 { 91 {
93 private static final Logger LOG = LoggerFactory.getLogger(AbstractHttpConnection.class); 92 private static final Logger LOG = LoggerFactory.getLogger(AbstractHttpConnection.class);
94 93
95 private int _requests; 94 private int _requests;
96 95
382 LOG.warn("header full: " + e); 381 LOG.warn("header full: " + e);
383 382
384 _response.reset(); 383 _response.reset();
385 _generator.reset(); 384 _generator.reset();
386 _generator.setResponse(HttpStatus.INTERNAL_SERVER_ERROR_500,null); 385 _generator.setResponse(HttpStatus.INTERNAL_SERVER_ERROR_500,null);
387 _generator.completeHeader(_responseFields,Generator.LAST); 386 _generator.completeHeader(_responseFields,HttpGenerator.LAST);
388 _generator.complete(); 387 _generator.complete();
389 throw new HttpException(HttpStatus.INTERNAL_SERVER_ERROR_500); 388 throw new HttpException(HttpStatus.INTERNAL_SERVER_ERROR_500);
390 } 389 }
391 390
392 } 391 }
399 if (!_generator.isCommitted()) 398 if (!_generator.isCommitted())
400 { 399 {
401 _generator.setResponse(_response.getStatus(), _response.getReason()); 400 _generator.setResponse(_response.getStatus(), _response.getReason());
402 try 401 try
403 { 402 {
404 _generator.completeHeader(_responseFields, Generator.LAST); 403 _generator.completeHeader(_responseFields, HttpGenerator.LAST);
405 } 404 }
406 catch(RuntimeException e) 405 catch(RuntimeException e)
407 { 406 {
408 LOG.warn("header full: "+e); 407 LOG.warn("header full: "+e);
409 LOG.debug("",e); 408 LOG.debug("",e);
410 409
411 _response.reset(); 410 _response.reset();
412 _generator.reset(); 411 _generator.reset();
413 _generator.setResponse(HttpStatus.INTERNAL_SERVER_ERROR_500,null); 412 _generator.setResponse(HttpStatus.INTERNAL_SERVER_ERROR_500,null);
414 _generator.completeHeader(_responseFields,Generator.LAST); 413 _generator.completeHeader(_responseFields,HttpGenerator.LAST);
415 _generator.complete(); 414 _generator.complete();
416 throw new HttpException(HttpStatus.INTERNAL_SERVER_ERROR_500); 415 throw new HttpException(HttpStatus.INTERNAL_SERVER_ERROR_500);
417 } 416 }
418 } 417 }
419 418
422 421
423 public final void flushResponse() throws IOException 422 public final void flushResponse() throws IOException
424 { 423 {
425 try 424 try
426 { 425 {
427 commitResponse(Generator.MORE); 426 commitResponse(HttpGenerator.MORE);
428 _generator.flushBuffer(); 427 _generator.flushBuffer();
429 } 428 }
430 catch(IOException e) 429 catch(IOException e)
431 { 430 {
432 throw (e instanceof EofException) ? e:new EofException(e); 431 throw (e instanceof EofException) ? e:new EofException(e);
732 { 731 {
733 if (isClosed()) 732 if (isClosed())
734 return; 733 return;
735 734
736 if (!super._generator.isCommitted()) 735 if (!super._generator.isCommitted())
737 commitResponse(Generator.LAST); 736 commitResponse(HttpGenerator.LAST);
738 else 737 else
739 flushResponse(); 738 flushResponse();
740 739
741 super.close(); 740 super.close();
742 } 741 }
748 */ 747 */
749 @Override 748 @Override
750 public void flush() throws IOException 749 public void flush() throws IOException
751 { 750 {
752 if (!super._generator.isCommitted()) 751 if (!super._generator.isCommitted())
753 commitResponse(Generator.MORE); 752 commitResponse(HttpGenerator.MORE);
754 super.flush(); 753 super.flush();
755 } 754 }
756 755
757 /* ------------------------------------------------------------ */ 756 /* ------------------------------------------------------------ */
758 /* 757 /*
790 } 789 }
791 790
792 // Process content. 791 // Process content.
793 if (content instanceof Buffer) 792 if (content instanceof Buffer)
794 { 793 {
795 super._generator.addContent((Buffer) content, Generator.LAST); 794 super._generator.addContent((Buffer) content, HttpGenerator.LAST);
796 commitResponse(Generator.LAST); 795 commitResponse(HttpGenerator.LAST);
797 } 796 }
798 else if (content instanceof InputStream) 797 else if (content instanceof InputStream)
799 { 798 {
800 InputStream in = (InputStream)content; 799 InputStream in = (InputStream)content;
801 800