Mercurial Hosting > luan
comparison src/org/eclipse/jetty/server/AbstractHttpConnection.java @ 981:f46de416e219
remove HttpInput
| author | Franklin Schmidt <fschmidt@gmail.com> |
|---|---|
| date | Sun, 16 Oct 2016 21:10:25 -0600 |
| parents | bd26bd9320e2 |
| children | dbecd7faa1f5 |
comparison
equal
deleted
inserted
replaced
| 980:bd26bd9320e2 | 981:f46de416e219 |
|---|---|
| 175 } | 175 } |
| 176 _expect100Continue=false; | 176 _expect100Continue=false; |
| 177 } | 177 } |
| 178 | 178 |
| 179 if (_in == null) | 179 if (_in == null) |
| 180 _in = new HttpInput(AbstractHttpConnection.this); | 180 _in = new HttpInput(); |
| 181 return _in; | 181 return _in; |
| 182 } | 182 } |
| 183 | 183 |
| 184 /* ------------------------------------------------------------ */ | 184 /* ------------------------------------------------------------ */ |
| 185 /** | 185 /** |
| 222 } | 222 } |
| 223 }; | 223 }; |
| 224 } | 224 } |
| 225 _writer.setCharacterEncoding(encoding); | 225 _writer.setCharacterEncoding(encoding); |
| 226 return _printWriter; | 226 return _printWriter; |
| 227 } | |
| 228 | |
| 229 public final boolean isEarlyEOF() | |
| 230 { | |
| 231 return _earlyEOF; | |
| 232 } | 227 } |
| 233 | 228 |
| 234 protected void reset() | 229 protected void reset() |
| 235 { | 230 { |
| 236 _parser.reset(); | 231 _parser.reset(); |
| 770 throw new IOException("Closed"); | 765 throw new IOException("Closed"); |
| 771 PrintWriter writer=getPrintWriter(null); | 766 PrintWriter writer=getPrintWriter(null); |
| 772 writer.print(s); | 767 writer.print(s); |
| 773 } | 768 } |
| 774 | 769 |
| 775 /* ------------------------------------------------------------ */ | |
| 776 public void sendResponse(Buffer response) throws IOException | 770 public void sendResponse(Buffer response) throws IOException |
| 777 { | 771 { |
| 778 ((HttpGenerator)super._generator).sendResponse(response); | 772 ((HttpGenerator)super._generator).sendResponse(response); |
| 779 } | 773 } |
| 780 | 774 |
| 781 /* ------------------------------------------------------------ */ | |
| 782 public void sendContent(Object content) throws IOException | 775 public void sendContent(Object content) throws IOException |
| 783 { | 776 { |
| 784 Resource resource=null; | 777 Resource resource=null; |
| 785 | 778 |
| 786 if (isClosed()) | 779 if (isClosed()) |
| 833 in.close(); | 826 in.close(); |
| 834 } | 827 } |
| 835 } | 828 } |
| 836 else | 829 else |
| 837 throw new IllegalArgumentException("unknown content type?"); | 830 throw new IllegalArgumentException("unknown content type?"); |
| 838 | 831 } |
| 839 | 832 } |
| 833 | |
| 834 | |
| 835 private final class HttpInput extends ServletInputStream | |
| 836 { | |
| 837 /* ------------------------------------------------------------ */ | |
| 838 /* | |
| 839 * @see java.io.InputStream#read() | |
| 840 */ | |
| 841 @Override | |
| 842 public int read() throws IOException | |
| 843 { | |
| 844 byte[] bytes = new byte[1]; | |
| 845 int read = read(bytes, 0, 1); | |
| 846 return read < 0 ? -1 : 0xff & bytes[0]; | |
| 847 } | |
| 848 | |
| 849 /* ------------------------------------------------------------ */ | |
| 850 /* | |
| 851 * @see java.io.InputStream#read(byte[], int, int) | |
| 852 */ | |
| 853 @Override | |
| 854 public int read(byte[] b, int off, int len) throws IOException | |
| 855 { | |
| 856 int l = -1; | |
| 857 Buffer content = _parser.blockForContent(getMaxIdleTime()); | |
| 858 if (content!=null) | |
| 859 l = content.get(b, off, len); | |
| 860 else if (_earlyEOF) | |
| 861 throw new EofException("early EOF"); | |
| 862 return l; | |
| 863 } | |
| 864 | |
| 865 @Override | |
| 866 public int available() throws IOException | |
| 867 { | |
| 868 return _parser.available(); | |
| 840 } | 869 } |
| 841 } | 870 } |
| 842 | 871 |
| 843 } | 872 } |
