View Javadoc

1   //
2   //  ========================================================================
3   //  Copyright (c) 1995-2013 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.nested;
20  
21  import java.io.IOException;
22  import javax.servlet.ServletInputStream;
23  import javax.servlet.http.HttpServletRequest;
24  import javax.servlet.http.HttpServletResponse;
25  
26  import org.eclipse.jetty.io.bio.StreamEndPoint;
27  
28  public class NestedEndPoint extends StreamEndPoint
29  {
30      private final HttpServletRequest _outerRequest;
31  
32      public NestedEndPoint(HttpServletRequest outerRequest, HttpServletResponse outerResponse)
33          throws IOException
34      {
35          super(outerRequest.getInputStream(),outerResponse.getOutputStream());
36          _outerRequest=outerRequest;
37      }
38  
39      public ServletInputStream getServletInputStream()
40      {
41          return (ServletInputStream)getInputStream();
42      }
43      @Override
44      public String getLocalAddr()
45      {
46          return _outerRequest.getLocalAddr();
47      }
48  
49      @Override
50      public String getLocalHost()
51      {
52          return _outerRequest.getLocalName();
53      }
54  
55      @Override
56      public int getLocalPort()
57      {
58          return _outerRequest.getLocalPort();
59      }
60  
61      @Override
62      public String getRemoteAddr()
63      {
64          return _outerRequest.getRemoteAddr();
65      }
66  
67      @Override
68      public String getRemoteHost()
69      {
70          return _outerRequest.getRemoteHost();
71      }
72      @Override
73      public int getRemotePort()
74      {
75          return _outerRequest.getRemotePort();
76      }
77  }