Unable to read the orginal url when host header is specified.

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Unable to read the orginal url when host header is specified.

Anurag Sharma

My code is running on local host and i am hitting one of my urls as below

 curl -k -vv --http1.1 "https://localhost:8443/versa/login" -H 'Host: google.com'

Now i m a trying to read the url in my code using following

StringBuffer url = httpServletRequest.getRequestURL();

The value is always as follows whether the  protocal HTTP/1.1 or HTTP/2
https://google.com/versa/login

how to read the original url here?



-------------------------------------------

Thanks and Regards,

Anurag Sharma.
Reply | Threaded
Open this post in threaded view
|

Re: Unable to read the orginal url when host header is specified.

markt
On 12/03/2021 01:50, Anurag Sharma wrote:

>
> My code is running on local host and i am hitting one of my urls as below
>
>   curl -k -vv --http1.1 "https://localhost:8443/versa/login" -H 'Host: google.com'
>
> Now i m a trying to read the url in my code using following
>
> StringBuffer url = httpServletRequest.getRequestURL();
>
> The value is always as follows whether the  protocal HTTP/1.1 or HTTP/2
> https://google.com/versa/login
>
> how to read the original url here?

Tomcat version?

Mark

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Unable to read the orginal url when host header is specified.

Anurag Sharma
I am using 9.0.31

Get Outlook for Android<https://aka.ms/ghei36>

________________________________
From: Mark Thomas <[hidden email]>
Sent: Thursday, March 11, 2021, 11:27 PM
To: [hidden email]
Subject: Re: Unable to read the orginal url when host header is specified.

On 12/03/2021 01:50, Anurag Sharma wrote:

>
> My code is running on local host and i am hitting one of my urls as below
>
>   curl -k -vv --http1.1 "https://localhost:8443/versa/login" -H 'Host: google.com'
>
> Now i m a trying to read the url in my code using following
>
> StringBuffer url = httpServletRequest.getRequestURL();
>
> The value is always as follows whether the  protocal HTTP/1.1 or HTTP/2
> https://nam10.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgoogle.com%2Fversa%2Flogin&amp;data=04%7C01%7Canurags%40versa-networks.com%7C8e4a356cdc8648af3dea08d8e5284124%7Cd39a23bd897c45f1a3f5c5213b673627%7C0%7C0%7C637511308345816627%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&amp;sdata=JIFrpVVF8e2YLZYZZbVnjYGp7VzNuxPb3POsUR5c1h8%3D&amp;reserved=0
>
> how to read the original url here?

Tomcat version?

Mark

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]


Reply | Threaded
Open this post in threaded view
|

Re: Unable to read the orginal url when host header is specified.

Christopher Schultz-2
In reply to this post by Anurag Sharma
Anaurag,

On 3/11/21 20:50, Anurag Sharma wrote:
> My code is running on local host and i am hitting one of my urls as
> below
>
> curl -k -vv --http1.1 "https://localhost:8443/versa/login" -H 'Host:
> google.com'
What do you think curl is sending to the server with the above command?
The -vv suggests that it will dump everything out. What does the request
line look like?

> Now i m a trying to read the url in my code using following
>
> StringBuffer url = httpServletRequest.getRequestURL();
>
> The value is always as follows whether the  protocal HTTP/1.1 or
> HTTP/2 https://google.com/versa/login
>
> how to read the original url here?

I think you will find that curl never sends the text "localhost:8443" to
the server, so it's not possible for the server to read that from the
request in any way.

-chris

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]