On Mon, 2011-06-27 at 22:17 +0530, Hiranya Jayathilaka wrote:
> Hi Devs,
> 
> Is there a way to get the actual URL requested by the client when receiving
> a message through HTTP Core API? For instance if we are implementing a web
> server using HTTP Core, and the user types in the URL
> http://test.com/1/2/3on his browser, is there a way to get the full
> URL including the
> test.com part in the server side code?
> 
> Thanks

Hiranya

Something like that should the trick, I think.

---
public URI getRequestURI(HttpRequest request) throws Exception {
    String path = request.getRequestLine().getUri();
    String host;
    Header h = request.getFirstHeader(HTTP.TARGET_HOST);
    if (h != null) {
        host = h.getValue();
    } else {
        host = InetAddress.getLocalHost().getCanonicalHostName();
    }
    return new URI("http", host, path, null);
}
---
Oleg



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

Reply via email to