Re: [Simpleweb-Support] Unable to get scheme/port/domain from incoming Request
Brought to you by:
niallg
From: Rastislav K. <kas...@gm...> - 2012-11-12 22:07:20
|
Maybe I'm out of picture a bit, but isn't this matter of your own code in connection setup? You know, once the connection is opened, it doesn't know, if it's secure or not. The scheme should be either http or https. But you have to decide if you want to listen on HTTP or HTTPS when performing SocketConnection.connect(), see: http://www.simpleframework.org/doc/javadoc/org/simpleframework/transport/connect/SocketConnection.html If you want to listen on both ports (80 and 443), then just create 2 Container wrappers, make them carry instance variable scheme = (http|https) and let them call your own handleWithScheme(String scheme, Request request, Response response) on wrapper container. Protocode as follows: interface SchemedContainer { public void handleWithScheme(String scheme, Request req, Response resp); } class SchemeContainerWrapper implements Container { private String scheme; private SchemeContainer wrappedContainer; public void handle(Request req, Response resp) { wrappedContainer.handleWithScheme(scheme, req, resp); } } schemeContainer = <some> SchemeContainer; httpContainer = new SchemeContainerWrapper('http', schemeContainer); httpConnection = new SocketConnection(httpContainer); httpConnection.connect(address); httpsContainer = new SchemeContainerWrapper('https', schemeContainer); httpsConnection = new SocketConnection(httpsContainer); httpsConnection.connect(address, sslContext); Or you can do it implementing request wrapper without introducing SchemedContainer, use what better suites your scenario. Hope this helps. Extend as you wish (multiple listening addresses, ports, etc,...), you get the idea. RK On Mon, Nov 12, 2012 at 9:50 PM, Tom Denley <t.d...@ca...> wrote: > Thanks Rastislav, > > I guess that makes sense. > > My question still remains though: what mechanism does Simple support > for determining the scheme of the request? > > Regards, > > -- Tom > > ------------------------------------------------------------------------------ > Monitor your physical, virtual and cloud infrastructure from a single > web console. Get in-depth insight into apps, servers, databases, vmware, > SAP, cloud infrastructure, etc. Download 30-day Free Trial. > Pricing starts from $795 for 25 servers or applications! > http://p.sf.net/sfu/zoho_dev2dev_nov > _______________________________________________ > Simpleweb-Support mailing list > Sim...@li... > https://lists.sourceforge.net/lists/listinfo/simpleweb-support |