You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mina.apache.org by Michael Bauroth <Mi...@falcom.de> on 2008/02/27 15:45:28 UTC
Example for use of http-filter-codec?
Hi,
I started my first steps diving into the mina-filter-codec-http world.
Has anybody eventually a little piece of code for the handler to respond
an incoming request? A bigger piece of code would naturally also be
welcome ;)
Best Regards
Michael
Re: Example for use of http-filter-codec?
Posted by Michael Bauroth <Mi...@falcom.de>.
Ok, seems that I found it by myself :)
Is this enough?
@Override
public void messageReceived( IoSession pSession, Object pMsg )
{
DefaultHttpResponse tResponse = new DefaultHttpResponse();
tResponse.setStatus( HttpResponseStatus.OK );
tResponse.setStatusReasonPhrase(
HttpResponseStatus.OK.getDescription() );
tResponse.setContentType( "text/plain" );
tResponse.setContent( IoBuffer.wrap( "SUCCESS".getBytes() ) );
pSession.write( tResponse ).addListener( IoFutureListener.CLOSE );
}
Best Regards
Michael
Re: Example for use of http-filter-codec?
Posted by Michael Bauroth <Mi...@falcom.de>.
Hi Alex,
Thank you for the quick response. It will definitely help!
Best Regards
Michael
Alex Karasulu schrieb:
> There's a good example of this in asyncweb-examples. I think it's the
> lightweight example which just uses the codec instead of the entire asyncweb
> container. Here's the module:
>
> http://svn.apache.org/repos/asf/mina/asyncweb/trunk/examples/
>
> Here's the class:
>
> http://svn.apache.org/repos/asf/mina/asyncweb/trunk/examples/src/main/java/org/apache/asyncweb/examples/lightweight/HttpProtocolHandler.java
>
> Alex
>
> On Wed, Feb 27, 2008 at 9:45 AM, Michael Bauroth <Mi...@falcom.de>
> wrote:
>
>> Hi,
>>
>> I started my first steps diving into the mina-filter-codec-http world.
>> Has anybody eventually a little piece of code for the handler to respond
>> an incoming request? A bigger piece of code would naturally also be
>> welcome ;)
>>
>> Best Regards
>> Michael
>>
>>
>
Re: Example for use of http-filter-codec?
Posted by Alex Karasulu <ak...@apache.org>.
There's a good example of this in asyncweb-examples. I think it's the
lightweight example which just uses the codec instead of the entire asyncweb
container. Here's the module:
http://svn.apache.org/repos/asf/mina/asyncweb/trunk/examples/
Here's the class:
http://svn.apache.org/repos/asf/mina/asyncweb/trunk/examples/src/main/java/org/apache/asyncweb/examples/lightweight/HttpProtocolHandler.java
Alex
On Wed, Feb 27, 2008 at 9:45 AM, Michael Bauroth <Mi...@falcom.de>
wrote:
> Hi,
>
> I started my first steps diving into the mina-filter-codec-http world.
> Has anybody eventually a little piece of code for the handler to respond
> an incoming request? A bigger piece of code would naturally also be
> welcome ;)
>
> Best Regards
> Michael
>
>