Also Hiranya, Do you think the following method you have used in your patch will work when there are multiple hostnames mapped to a single machine;
NhttpUtil.getHostName(httpConn.getLocalAddress()) My requirement is to simply get the Host from the request. For example, on my machine, I have appserver.cloud-test.wso2.com, esb.cloud-test.wso2.cometc. all mapped to 127.0.0.1 On Sun, Jun 26, 2011 at 11:48 AM, Afkham Azeez <az...@wso2.com> wrote: > > > On Sun, Jun 26, 2011 at 11:34 AM, Hiranya Jayathilaka <hira...@wso2.com>wrote: > >> Hi, >> >> Please try applying the attached patch on Synapse >> (modules/transports/core/nhttp). It uses the Host header to construct the >> full URI. If the header is not present it uses the information available in >> the connection object. HTTP spec mandates that all requests contain the Host >> header. So most of the time URI will be constructed using the header. >> > > Well, you said earlier that clients may not send the Host header. If the > HTTP spec mandates the Host header, then such clients are violating the spec > right? So, from our end, it is not unreasonable to assume that the client > always send the Host header, right? > > >> >> The full URI will be stored in Constants.Configuration.TRANSPORT_IN_URL. >> >> Thanks, >> Hiranya >> >> >> On Sat, Jun 25, 2011 at 10:15 PM, Afkham Azeez <az...@wso2.com> wrote: >> >>> >>> >>> On Sat, Jun 25, 2011 at 9:47 PM, Afkham Azeez <az...@wso2.com> wrote: >>> >>>> Hiranya, >>>> Can you please coders that. The servlet API provides such information so >>>> this is a shortcoming of the nhttp transport. >>>> >>> >>> Oops... this is what happens when you use the phone keyboard :) I meant, >>> can you please fix this so that we can use it in the LB? >>> >>> >>> >>>> On Jun 25, 2011 9:33 PM, "Hiranya Jayathilaka" <hira...@wso2.com> >>>> wrote: >>>> > The original request uri is not part of the message. So we cannot >>>> obtain it from the http message. But at the transport level we can infer it >>>> by looking at the socket. Currently nhttp transport doesn't do that. We can >>>> add that bit of logic to the transport if needed. >>>> > >>>> > Sent from my iPhone >>>> > >>>> > On Jun 25, 2011, at 8:45 AM, Afkham Azeez <az...@wso2.com> wrote: >>>> > >>>> >> >>>> >> >>>> >> On Sat, Jun 25, 2011 at 8:24 PM, Hiranya Jayathilaka < >>>> hira...@wso2.com> wrote: >>>> >> This means you rely on the client to always send the Host header. >>>> Might not always work. >>>> >> >>>> >> Is there a way to get the originally requested URL? >>>> >> >>>> >> Sent from my iPhone >>>> >> >>>> >> On Jun 24, 2011, at 9:18 PM, Afkham Azeez <az...@wso2.com> wrote: >>>> >> >>>> >>> The following code works. >>>> >>> >>>> >>> Map<String, String> headers = (Map<String, >>>> String>)((Axis2MessageContext) >>>> synCtx).getAxis2MessageContext().getProperty(org.apache.axis2.context.MessageContext.TRANSPORT_HEADERS); >>>> >>> >>>> >>> String address = headers.get("Host"); >>>> >>> >>>> >>> On Sat, Jun 25, 2011 at 9:36 AM, Afkham Azeez <az...@wso2.com> >>>> wrote: >>>> >>> >>>> >>> >>>> >>> On Sat, Jun 25, 2011 at 4:47 AM, Hiranya Jayathilaka < >>>> hira...@wso2.com> wrote: >>>> >>> I found following on simple HTTP server code: >>>> >>> >>>> >>> msgContext.setProperty(MessageContext.TRANSPORT_ADDR, >>>> >>> conn.getLocalAddress().getHostAddress()); >>>> >>> >>>> >>> This returns null for the NHTTP transport >>>> >>> >>>> >>> But other transports doesn't seem to be setting this. I didn't find >>>> anything relevant in servlet transport code :( >>>> >>> >>>> >>> Thanks, >>>> >>> Hiranya >>>> >>> >>>> >>> On Sat, Jun 25, 2011 at 3:48 AM, Hiranya Jayathilaka < >>>> hira...@wso2.com> wrote: >>>> >>> >>>> >>> >>>> >>> On Sat, Jun 25, 2011 at 3:07 AM, Afkham Azeez <az...@wso2.com> >>>> wrote: >>>> >>> Sorry, this does not work. I had hardcoded the host for testing it, >>>> so for subsequent requests that prop was there. >>>> >>> >>>> >>> It doesn't look like we are keeping track of the full request URI >>>> while mediation. The NHTTP transport sets a property named "TransportInURL" >>>> (which I think other transports are setting too) on Axis2 message context >>>> upon receiving a request. But I'm not sure even that will give the full >>>> URL. >>>> Here's the implementation from NHTTP transport: >>>> >>> >>>> >>> msgContext.setProperty( >>>> >>> Constants.Configuration.TRANSPORT_IN_URL, >>>> request.getRequestLine().getUri()); >>>> >>> >>>> >>> Very often the URI extracted from the request line is a relative URI >>>> and so will not contain the hostname part. Worth trying out though. >>>> >>> >>>> >>> BTW can't we just infer the hostname part since we know the hostname >>>> of the server where the code is running? >>>> >>> >>>> >>> Thanks, >>>> >>> Hiranya >>>> >>> >>>> >>> >>>> >>> >>>> >>> On Sat, Jun 25, 2011 at 2:57 AM, Afkham Azeez <az...@wso2.com> >>>> wrote: >>>> >>> I found a way to get this. Hope it is the proper way of handling >>>> this. >>>> >>> >>>> >>> >>>> ((Axis2MessageContext)synCtx).getAxis2MessageContext().getConfigurationContext().getProperty("synapse.endpoint.lb.algorithm.sdlbEndpointhost") >>>> >>>> >>> >>>> >>> >>>> >>> On Sat, Jun 25, 2011 at 2:39 AM, Afkham Azeez <az...@wso2.com> >>>> wrote: >>>> >>> Folks, >>>> >>> To implement the Service-aware LB, I need to get the requested host >>>> name. The MessageContext.getTo() method does not return the hostname part. >>>> Is there any other way to get this, perhaps from the transport headers? >>>> >>> >>>> >>> Thanks >>>> >>> Azeez >>>> >>> >>>> >>> -- >>>> >>> Afkham Azeez >>>> >>> Director of Architecture; WSO2, Inc.; http://wso2.com >>>> >>> Member; Apache Software Foundation; http://www.apache.org/ >>>> >>> >>>> >>> email: az...@wso2.com cell: +94 77 3320919 >>>> >>> blog: http://blog.afkham.org >>>> >>> twitter: http://twitter.com/afkham_azeez >>>> >>> linked-in: http://lk.linkedin.com/in/afkhamazeez >>>> >>> >>>> >>> Lean . Enterprise . Middleware >>>> >>> >>>> >>> >>>> >>> >>>> >>> >>>> >>> -- >>>> >>> Afkham Azeez >>>> >>> Director of Architecture; WSO2, Inc.; http://wso2.com >>>> >>> Member; Apache Software Foundation; http://www.apache.org/ >>>> >>> >>>> >>> email: az...@wso2.com cell: +94 77 3320919 >>>> >>> blog: http://blog.afkham.org >>>> >>> twitter: http://twitter.com/afkham_azeez >>>> >>> linked-in: http://lk.linkedin.com/in/afkhamazeez >>>> >>> >>>> >>> Lean . Enterprise . Middleware >>>> >>> >>>> >>> >>>> >>> >>>> >>> >>>> >>> -- >>>> >>> Afkham Azeez >>>> >>> Director of Architecture; WSO2, Inc.; http://wso2.com >>>> >>> Member; Apache Software Foundation; http://www.apache.org/ >>>> >>> >>>> >>> email: az...@wso2.com cell: +94 77 3320919 >>>> >>> blog: http://blog.afkham.org >>>> >>> twitter: http://twitter.com/afkham_azeez >>>> >>> linked-in: http://lk.linkedin.com/in/afkhamazeez >>>> >>> >>>> >>> Lean . Enterprise . Middleware >>>> >>> >>>> >>> >>>> >>> _______________________________________________ >>>> >>> Carbon-dev mailing list >>>> >>> Carbon-dev@wso2.org >>>> >>> http://mail.wso2.org/cgi-bin/mailman/listinfo/carbon-dev >>>> >>> >>>> >>> >>>> >>> >>>> >>> >>>> >>> -- >>>> >>> Hiranya Jayathilaka >>>> >>> Associate Technical Lead; >>>> >>> WSO2 Inc.; http://wso2.org >>>> >>> E-mail: hira...@wso2.com; Mobile: +94 77 633 3491 >>>> >>> Blog: http://techfeast-hiranya.blogspot.com >>>> >>> >>>> >>> >>>> >>> >>>> >>> -- >>>> >>> Hiranya Jayathilaka >>>> >>> Associate Technical Lead; >>>> >>> WSO2 Inc.; http://wso2.org >>>> >>> E-mail: hira...@wso2.com; Mobile: +94 77 633 3491 >>>> >>> Blog: http://techfeast-hiranya.blogspot.com >>>> >>> >>>> >>> _______________________________________________ >>>> >>> Carbon-dev mailing list >>>> >>> Carbon-dev@wso2.org >>>> >>> http://mail.wso2.org/cgi-bin/mailman/listinfo/carbon-dev >>>> >>> >>>> >>> >>>> >>> >>>> >>> >>>> >>> -- >>>> >>> Afkham Azeez >>>> >>> Director of Architecture; WSO2, Inc.; http://wso2.com >>>> >>> Member; Apache Software Foundation; http://www.apache.org/ >>>> >>> >>>> >>> email: az...@wso2.com cell: +94 77 3320919 >>>> >>> blog: http://blog.afkham.org >>>> >>> twitter: http://twitter.com/afkham_azeez >>>> >>> linked-in: http://lk.linkedin.com/in/afkhamazeez >>>> >>> >>>> >>> Lean . Enterprise . Middleware >>>> >>> >>>> >>> >>>> >>> >>>> >>> >>>> >>> -- >>>> >>> Afkham Azeez >>>> >>> Director of Architecture; WSO2, Inc.; http://wso2.com >>>> >>> Member; Apache Software Foundation; http://www.apache.org/ >>>> >>> >>>> >>> email: az...@wso2.com cell: +94 77 3320919 >>>> >>> blog: http://blog.afkham.org >>>> >>> twitter: http://twitter.com/afkham_azeez >>>> >>> linked-in: http://lk.linkedin.com/in/afkhamazeez >>>> >>> >>>> >>> Lean . Enterprise . Middleware >>>> >>> >>>> >>> _______________________________________________ >>>> >>> Carbon-dev mailing list >>>> >>> Carbon-dev@wso2.org >>>> >>> http://mail.wso2.org/cgi-bin/mailman/listinfo/carbon-dev >>>> >> >>>> >> _______________________________________________ >>>> >> Carbon-dev mailing list >>>> >> Carbon-dev@wso2.org >>>> >> http://mail.wso2.org/cgi-bin/mailman/listinfo/carbon-dev >>>> >> >>>> >> >>>> >> >>>> >> >>>> >> -- >>>> >> Afkham Azeez >>>> >> Director of Architecture; WSO2, Inc.; http://wso2.com >>>> >> Member; Apache Software Foundation; http://www.apache.org/ >>>> >> >>>> >> email: az...@wso2.com cell: +94 77 3320919 >>>> >> blog: http://blog.afkham.org >>>> >> twitter: http://twitter.com/afkham_azeez >>>> >> linked-in: http://lk.linkedin.com/in/afkhamazeez >>>> >> >>>> >> Lean . Enterprise . Middleware >>>> >> >>>> >> _______________________________________________ >>>> >> Carbon-dev mailing list >>>> >> Carbon-dev@wso2.org >>>> >> http://mail.wso2.org/cgi-bin/mailman/listinfo/carbon-dev >>>> >>> >>> >>> >>> -- >>> *Afkham Azeez* >>> Director of Architecture; WSO2, Inc.; http://wso2.com >>> Member; Apache Software Foundation; http://www.apache.org/ >>> * <http://www.apache.org/>** >>> email: **az...@wso2.com* <az...@wso2.com>* cell: +94 77 3320919 >>> blog: **http://blog.afkham.org* <http://blog.afkham.org>* >>> twitter: **http://twitter.com/afkham_azeez*<http://twitter.com/afkham_azeez> >>> * >>> linked-in: **http://lk.linkedin.com/in/afkhamazeez* >>> * >>> * >>> *Lean . Enterprise . Middleware* >>> >>> >>> _______________________________________________ >>> Carbon-dev mailing list >>> Carbon-dev@wso2.org >>> http://mail.wso2.org/cgi-bin/mailman/listinfo/carbon-dev >>> >>> >> >> >> -- >> Hiranya Jayathilaka >> Associate Technical Lead; >> WSO2 Inc.; http://wso2.org >> E-mail: hira...@wso2.com; Mobile: +94 77 633 3491 >> Blog: http://techfeast-hiranya.blogspot.com >> >> _______________________________________________ >> Carbon-dev mailing list >> Carbon-dev@wso2.org >> http://mail.wso2.org/cgi-bin/mailman/listinfo/carbon-dev >> >> > > > -- > *Afkham Azeez* > Director of Architecture; WSO2, Inc.; http://wso2.com > Member; Apache Software Foundation; http://www.apache.org/ > * <http://www.apache.org/>** > email: **az...@wso2.com* <az...@wso2.com>* cell: +94 77 3320919 > blog: **http://blog.afkham.org* <http://blog.afkham.org>* > twitter: **http://twitter.com/afkham_azeez*<http://twitter.com/afkham_azeez> > * > linked-in: **http://lk.linkedin.com/in/afkhamazeez* > * > * > *Lean . Enterprise . Middleware* > > -- *Afkham Azeez* Director of Architecture; WSO2, Inc.; http://wso2.com Member; Apache Software Foundation; http://www.apache.org/ * <http://www.apache.org/>** email: **az...@wso2.com* <az...@wso2.com>* cell: +94 77 3320919 blog: **http://blog.afkham.org* <http://blog.afkham.org>* twitter: **http://twitter.com/afkham_azeez*<http://twitter.com/afkham_azeez> * linked-in: **http://lk.linkedin.com/in/afkhamazeez* * * *Lean . Enterprise . Middleware*
_______________________________________________ Carbon-dev mailing list Carbon-dev@wso2.org http://mail.wso2.org/cgi-bin/mailman/listinfo/carbon-dev