On Tue, Jun 28, 2011 at 1:12 AM, Oleg Kalnichevski <[email protected]> wrote:
> 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. > Thanks Oleg. This is pretty much what I had in my mind as well. Just needed to get it confirmed. Thanks, Hiranya > > --- > 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] > > -- Hiranya Jayathilaka Senior Software Engineer; WSO2 Inc.; http://wso2.org E-mail: [email protected]; Mobile: +94 77 633 3491 Blog: http://techfeast-hiranya.blogspot.com
