Hi Monika, On Nov 27, 2007 1:21 AM, monika7 <[EMAIL PROTECTED]> wrote: > > > Trustin Lee wrote: > > > > Hi Monica, > > > > On Nov 22, 2007 4:58 AM, monika7 <[EMAIL PROTECTED]> wrote: > >> I just discovered the new version of HTTPResponse vs old > >> HTTPResponseMessage > >> and I noticed one difference in the outcome of getContent() method. > >> The original HTTPResponseMessage had getStringContent() method which > >> returned just the body of the message. If I use HTTPResponse.getContent > >> and > >> convert the return IOBuffer to a String, I get the whole message, > >> including > >> all http headers. I am enclosing below the output of the following code > >> where httpResponse is instance of DefaultHttpResponse class: > >> > >> IoBuffer content = httpResponse.getContent(); > >> byte[] contentBytes = content.array(); > >> String contentString = new String(contentBytes); > > > > I think you have to do the following: > > > > IoBuffer content = httpResponse.getContent(); > > String contentString = > > content.getString(Charset.forName(...).newDecoder()); > > > > > > This worked, so now my http client is fixed. > If I were to use the same HTTPResponse/Request objects on my server side > (instead of the classes in http server example) - can you give some pointers > what need to be done to do the conversion. Would the same HttpCodecFactory I > used on client side work on the server side?
Yes, the same HttpCodecFactory is used. It automatically decides what encoder and decoder is going to be used. You could take a look at the following example: http://svn.apache.org/viewvc/mina/sandbox/asyncweb/example/src/main/java/org/safehaus/asyncweb/example/lightweight/ HTH, Trustin -- what we call human nature is actually human habit -- http://gleamynode.net/ -- PGP Key ID: 0x0255ECA6
