Re: [Simpleweb-Support] Missing getInetAddress on Request in Simple v4.0
Brought to you by:
niallg
From: Niall G. <gal...@ya...> - 2008-08-18 18:28:17
|
Hi, Do this: Container container = new MyContainer(); Processor processor = new ContainerProcessor(container, 10); Connection connection = new SocketConnection(processor); So, if you like you can wrap the ContainerProcessor in your implementation of the processor. It works like this. Conection -> Processor -> Container Hope this helps, Niall --- On Mon, 8/18/08, Niels-Ole Gram <no...@c3...> wrote: > From: Niels-Ole Gram <no...@c3...> > Subject: Re: [Simpleweb-Support] Missing getInetAddress on Request in Simple v4.0 > To: gal...@ya..., "Simple support and user issues" <sim...@li...> > Date: Monday, August 18, 2008, 5:50 AM > Hi Niall, > > Thanks for you fast reply. This will probably solve my > problem, though I > have a problem with an already existing Container. My code > looks like this: > > Container container = new MyContainer(); > Connection connection = new > SocketConnection(container); > connection.connect(new > InetSocketAddress(port)); > > This means that I already got a container, which adds a > couple of headers to > the reply, but now I would like to add the new processor as > well. How is > this accomplished? > > Thanks again. > > > Regards, > A user of Simple > > On Mon, Aug 18, 2008 at 2:15 PM, Niall Gallagher > <gal...@ya...>wrote: > > > Hi, > > > > Ya its still possible to get the client address. Here > is what to do. > > > > public class MyProcessor implements Processor { > > > > private Processor processor; > > > > public MyProcessor(Processor processor) { > > this.processor = processor; > > } > > > > public void process(Pipeline pipeline) throws > Exception { > > Map map = pipeline.getAttributes(); > > Socket socket = pipeline.getSocket().socket(); // > get socket > > InetAddress address = socket.getInetAddress(); // > get client address > > > > map.put("myKeyForAddres", address); > > processor.process(pipeline); // forward to main > processor > > } > > > > public void stop() throws Exception { > > processor.stop(); > > } > > } > > > > Then with your request you can get. > > > > InetAddress address = > request.getAttributes().get("myKeyForAddress"); > > > > This kind of attribute passing can also be used for > handing over SSL > > certificates, and other connection based properties. I > will add the > > getInetAddress as getClientAddress in a future > release. > > > > Regards, > > Niall > > > > --- On Mon, 8/18/08, zwj...@sn... > <zwj...@sn...> > > wrote: > > > > > From: zwj...@sn... > <zwj...@sn...> > > > Subject: [Simpleweb-Support] Missing > getInetAddress on Request in Simple > > v4.0 > > > To: sim...@li... > > > Date: Monday, August 18, 2008, 4:55 AM > > > Hi, > > > > > > Great work on the new version of Simple! I am > missing the > > > old method getInetAddress() on Request - how come > this has > > > been removed in the new version? Is it possible > to somehow > > > get the address of the client requesting a > resource? > > > > > > Thanks. > > > > > > > > > Regards, > > > A user of Simple > > > > > > -------------------------------------- > > > Protect yourself from spam, > > > use http://sneakemail.com > > > > > > > ------------------------------------------------------------------------- > > > This SF.Net email is sponsored by the Moblin Your > Move > > > Developer's challenge > > > Build the coolest Linux based applications with > Moblin SDK > > > & win great prizes > > > Grand prize is a trip for two to an Open Source > event > > > anywhere in the world > > > > http://moblin-contest.org/redirect.php?banner_id=100&url=/ > > > _______________________________________________ > > > Simpleweb-Support mailing list > > > Sim...@li... > > > > https://lists.sourceforge.net/lists/listinfo/simpleweb-support > > > > > > > > > > > ------------------------------------------------------------------------- > > This SF.Net email is sponsored by the Moblin Your Move > Developer's > > challenge > > Build the coolest Linux based applications with Moblin > SDK & win great > > prizes > > Grand prize is a trip for two to an Open Source event > anywhere in the world > > > http://moblin-contest.org/redirect.php?banner_id=100&url=/ > > _______________________________________________ > > Simpleweb-Support mailing list > > Sim...@li... > > > https://lists.sourceforge.net/lists/listinfo/simpleweb-support > > > > > > -- > Med venlig hilsen > > Niels-Ole Gram > Udviklingschef / CTO > C3A Medical A/S, Denmark > > Finlandsgade 10 > DK-8200 Aarhus N > > +45 50530302 > no...@c3... > http://www.c3a.dk/ > ------------------------------------------------------------------------- > This SF.Net email is sponsored by the Moblin Your Move > Developer's challenge > Build the coolest Linux based applications with Moblin SDK > & win great prizes > Grand prize is a trip for two to an Open Source event > anywhere in the world > http://moblin-contest.org/redirect.php?banner_id=100&url=/_______________________________________________ > Simpleweb-Support mailing list > Sim...@li... > https://lists.sourceforge.net/lists/listinfo/simpleweb-support |