2013/6/11 Anil Goyal -X (anigoyal - Aricent Technologies at Cisco)
<anigo...@cisco.com>:
>
> Please consider the code flow as below:
>
> HttpClient client = new HttpClient();
> portNumber = secure ? LocalNetworkConstants.DEFAULT_HTTPS_PORT : 
> LocalNetworkConstants.DEFAULT_HTTP_PORT; // DEFAULT_HTTPS_PORT=8444 and 
> DEFAULT_HTTP_PORT=8081 define in  LocalNetworkConstants.java  LOG.debug("the 
> value of https port is"+String.valueOf(portNumber)); if (secure) {
>         Protocol protocol = new 
> Protocol(LocalNetworkConstants.URISCHEME_HTTPS, new 
> ExtendedProtocolSocketFactory(address, 
> locationData.isAcceptSelfSignedCertificates(), 
> locationData.isAcceptCertificateErrors()) , portNumber);
>         client.getHostConfiguration().setHost(address, portNumber, protocol);
>          LOG.debug("setting the host for https"+String.valueOf(portNumber));
>     }
>     else {
>         client.getHostConfiguration().setHost(address, portNumber);
>         LOG.debug("setting the host for http"+String.valueOf(portNumber));
>     }
>
>
> GetMethod method = new GetMethod(LocalNetworkConstants.INFO_FEEDER_PATH);
> int returnCode = client.executeMethod(method);
>
> This is the code at the client side.
>
> At the server side,
>
> I have 8444 and 8081 port defined in server.xml
>
> <Connector URIEncoding="UTF-8" acceptCount="100" connectionTimeout="20000" 
> disableUploadTimeout="true" enableLookups="false" maxHttpHeaderSize="8193" 
> maxSpareThreads="25" maxThreads="25" minSpareThreads="10" port="8081" 
> protocol="HTTP/1.1" redirectPort="8444" server=" "/>
>     <Connector SSLEnabled="true" URIEncoding="UTF-8" acceptCount="100" 
> ciphers=" " clientAuth="false" disableUploadTimeout="true" 
> enableLookups="false" keystoreFile="" keystorePass="" keystoreType="" 
> maxHttpHeaderSize="8192" maxSpareThreads="25" maxThreads="25" 
> minSpareThreads="10" port="8444" protocol="HTTP/1.1" scheme="https" 
> secure="true" server=" " sslProtocol="TLS"/>
>
> Also I have these two ports entry in iptables.
>
> Now in the tomcat redirection valve, I have below code written
>
> int port = request.getServerPort();
> StringBuffer url = request.getRequestURL();
>
>
> So now the problem are is, when from client I disable ssl and send the 
> request at port 8081 then in tomcat valve, port -8081 and url also contains 
> port 8081.
>
> But when from client , I enable ssl and send the request at port 8444, then 
> here in valve the request.getServerPort returns 443 and even in url also port 
> is 443.
>
> So I am not able to understand why the https port is converting into 443 from 
> 8444 while http port 8081 is working fine.
>
> Even in tomcat access valve, the request is coming at port 8444 as shown below
> [11/Jun/2013:11:16:58 +0530] 10.93.230.203 10.93.230.203 admin - 8444 GET 
> /feeder/info HTTP/1.1 500 2581 123
>
> For http port also the request is coming at port 8081 of tomcat
> [11/Jun/2013:11:18:29 +0530] 10.93.230.203 10.93.230.203 admin - 8081 GET 
> /feeder/info HTTP/1.1 200 4377 286
>
> But I am totally confused why request.getServerPort is giving 443 for https 
> ???
>

AccessLogValve uses the same getServerPort() call, though directly on
a tomcat-internal request object.

So maybe your request is wrapped by some HttpServletRequestWrapper
(which overrides getServerPort() method and provides a different
value)?

Try to connect a debugger and step into that getServerPort() call.
https://wiki.apache.org/tomcat/FAQ/Developing#Debugging

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to