comparison src/org/eclipse/jetty/server/HttpInput.java @ 802:3428c60d7cfc

replace jetty jars with source
author Franklin Schmidt <fschmidt@gmail.com>
date Wed, 07 Sep 2016 21:15:48 -0600
parents
children 5ee36654b383
comparison
equal deleted inserted replaced
801:6a21393191c1 802:3428c60d7cfc
1 //
2 // ========================================================================
3 // Copyright (c) 1995-2014 Mort Bay Consulting Pty. Ltd.
4 // ------------------------------------------------------------------------
5 // All rights reserved. This program and the accompanying materials
6 // are made available under the terms of the Eclipse Public License v1.0
7 // and Apache License v2.0 which accompanies this distribution.
8 //
9 // The Eclipse Public License is available at
10 // http://www.eclipse.org/legal/epl-v10.html
11 //
12 // The Apache License v2.0 is available at
13 // http://www.opensource.org/licenses/apache2.0.php
14 //
15 // You may elect to redistribute this code under either of these licenses.
16 // ========================================================================
17 //
18
19 package org.eclipse.jetty.server;
20
21 import java.io.IOException;
22
23 import javax.servlet.ServletInputStream;
24
25 import org.eclipse.jetty.http.HttpParser;
26 import org.eclipse.jetty.io.Buffer;
27 import org.eclipse.jetty.io.EofException;
28
29 public class HttpInput extends ServletInputStream
30 {
31 protected final AbstractHttpConnection _connection;
32 protected final HttpParser _parser;
33
34 /* ------------------------------------------------------------ */
35 public HttpInput(AbstractHttpConnection connection)
36 {
37 _connection=connection;
38 _parser=(HttpParser)connection.getParser();
39 }
40
41 /* ------------------------------------------------------------ */
42 /*
43 * @see java.io.InputStream#read()
44 */
45 @Override
46 public int read() throws IOException
47 {
48 byte[] bytes = new byte[1];
49 int read = read(bytes, 0, 1);
50 return read < 0 ? -1 : 0xff & bytes[0];
51 }
52
53 /* ------------------------------------------------------------ */
54 /*
55 * @see java.io.InputStream#read(byte[], int, int)
56 */
57 @Override
58 public int read(byte[] b, int off, int len) throws IOException
59 {
60 int l=-1;
61 Buffer content=_parser.blockForContent(_connection.getMaxIdleTime());
62 if (content!=null)
63 l= content.get(b, off, len);
64 else if (_connection.isEarlyEOF())
65 throw new EofException("early EOF");
66 return l;
67 }
68
69 /* ------------------------------------------------------------ */
70 @Override
71 public int available() throws IOException
72 {
73 return _parser.available();
74 }
75 }