View Javadoc

1   // ========================================================================
2   // Copyright (c) 2010-2011 Mort Bay Consulting Pty. Ltd.
3   // ------------------------------------------------------------------------
4   // All rights reserved. This program and the accompanying materials
5   // are made available under the terms of the Eclipse Public License v1.0
6   // and Apache License v2.0 which accompanies this distribution.
7   // The Eclipse Public License is available at 
8   // http://www.eclipse.org/legal/epl-v10.html
9   // The Apache License v2.0 is available at
10  // http://www.opensource.org/licenses/apache2.0.php
11  // You may elect to redistribute this code under either of these licenses. 
12  // ========================================================================
13  package org.eclipse.jetty.nested;
14  
15  import java.io.IOException;
16  import java.io.InputStream;
17  import java.io.OutputStream;
18  
19  import javax.servlet.ServletInputStream;
20  import javax.servlet.http.HttpServletRequest;
21  import javax.servlet.http.HttpServletResponse;
22  
23  import org.eclipse.jetty.io.Buffer;
24  import org.eclipse.jetty.io.bio.StreamEndPoint;
25  
26  public class NestedEndPoint extends StreamEndPoint
27  {
28      private final HttpServletRequest _outerRequest;
29      
30      public NestedEndPoint(HttpServletRequest outerRequest, HttpServletResponse outerResponse)
31          throws IOException
32      {
33          super(outerRequest.getInputStream(),outerResponse.getOutputStream());
34          _outerRequest=outerRequest;
35      }
36  
37      public ServletInputStream getServletInputStream()
38      {
39          return (ServletInputStream)getInputStream();
40      }
41      @Override
42      public String getLocalAddr()
43      {
44          return _outerRequest.getLocalAddr();
45      }
46  
47      @Override
48      public String getLocalHost()
49      {
50          return _outerRequest.getLocalName();
51      }
52  
53      @Override
54      public int getLocalPort()
55      {
56          return _outerRequest.getLocalPort();
57      }
58  
59      @Override
60      public String getRemoteAddr()
61      {
62          return _outerRequest.getRemoteAddr();
63      }
64  
65      @Override
66      public String getRemoteHost()
67      {
68          // TODO Auto-generated method stub
69          return _outerRequest.getRemoteHost();
70      }
71      @Override
72      public int getRemotePort()
73      {
74          return _outerRequest.getRemotePort();
75      }
76  }