Skip to content

Get HTTP response body #441

@LittaKake

Description

@LittaKake

Hi!

I am trying to get the http body of the response.

So far I have under HttpFiltersSourceAdapter added

@Override
 public int getMaximumRequestBufferSizeInBytes() {
        return 1048576;
}

I am able to
System.out.println(httpObject.toString());

But when I try to cast the HttpObject to FullHttpResponse like this ((FullHttpResponse) httpObject).content(); I get an error like below

`Exception in thread "Thread-42" java.lang.ClassCastException: class io.netty.handler.codec.http.DefaultHttpResponse cannot be cast to class io.netty.handler.codec.http.FullHttpResponse (io.netty.handler.codec.http.DefaultHttpResponse and io.netty.handler.codec.http.FullHttpResponse are in module netty.all@4.0.44.Final of loader 'app')
at sample/sample.HttpResponseHandler.run(HttpResponseHandler.java:18)
at java.base/java.lang.Thread.run(Thread.java:832)

Exception in thread "Thread-43" Exception in thread "Thread-44" java.lang.ClassCastException: class io.netty.handler.codec.http.LastHttpContent$1 cannot be cast to class io.netty.handler.codec.http.FullHttpResponse (io.netty.handler.codec.http.LastHttpContent$1 and io.netty.handler.codec.http.FullHttpResponse are in module netty.all@4.0.44.Final of loader 'app')
at sample/sample.HttpResponseHandler.run(HttpResponseHandler.java:18)
at java.base/java.lang.Thread.run(Thread.java:832)

java.lang.ClassCastException: class io.netty.handler.codec.http.DefaultHttpContent cannot be cast to class io.netty.handler.codec.http.FullHttpResponse (io.netty.handler.codec.http.DefaultHttpContent and io.netty.handler.codec.http.FullHttpResponse are in module netty.all@4.0.44.Final of loader 'app')
at sample/sample.HttpResponseHandler.run(HttpResponseHandler.java:18)
at java.base/java.lang.Thread.run(Thread.java:832)

Exception in thread "Thread-45" java.lang.ClassCastException: class io.netty.handler.codec.http.DefaultHttpResponse cannot be cast to class io.netty.handler.codec.http.FullHttpResponse (io.netty.handler.codec.http.DefaultHttpResponse and io.netty.handler.codec.http.FullHttpResponse are in module netty.all@4.0.44.Final of loader 'app')
at sample/sample.HttpResponseHandler.run(HttpResponseHandler.java:18)
at java.base/java.lang.Thread.run(Thread.java:832)

`

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions