Search in sources :

Example 66 with HttpObject

use of io.netty.handler.codec.http.HttpObject in project netty by netty.

the class RtspDecoderTest method testReceiveAnnounce.

/**
 * There was a problem when an ANNOUNCE request was issued by the server,
 * i.e. entered through the response decoder. First the decoder failed to
 * parse the ANNOUNCE request, then it stopped receiving any more
 * responses. This test verifies that the issue is solved.
 */
@Test
public void testReceiveAnnounce() {
    byte[] data1 = ("ANNOUNCE rtsp://172.20.184.218:554/d3abaaa7-65f2-" + "42b4-8d6b-379f492fcf0f RTSP/1.0\r\n" + "CSeq: 2\r\n" + "Session: 2777476816092819869\r\n" + "x-notice: 5402 \"Session Terminated by Server\" " + "event-date=20150514T075303Z\r\n" + "Range: npt=0\r\n\r\n").getBytes();
    byte[] data2 = ("RTSP/1.0 200 OK\r\n" + "Server: Orbit2x\r\n" + "CSeq: 172\r\n" + "Session: 2547019973447939919\r\n" + "\r\n").getBytes();
    EmbeddedChannel ch = new EmbeddedChannel(new RtspDecoder(), new HttpObjectAggregator(1048576));
    ch.writeInbound(Unpooled.wrappedBuffer(data1), Unpooled.wrappedBuffer(data2));
    HttpObject res1 = ch.readInbound();
    assertNotNull(res1);
    assertTrue(res1 instanceof FullHttpRequest);
    ((FullHttpRequest) res1).release();
    HttpObject res2 = ch.readInbound();
    assertNotNull(res2);
    assertTrue(res2 instanceof FullHttpResponse);
    ((FullHttpResponse) res2).release();
}
Also used : HttpObjectAggregator(io.netty.handler.codec.http.HttpObjectAggregator) FullHttpRequest(io.netty.handler.codec.http.FullHttpRequest) HttpObject(io.netty.handler.codec.http.HttpObject) EmbeddedChannel(io.netty.channel.embedded.EmbeddedChannel) FullHttpResponse(io.netty.handler.codec.http.FullHttpResponse) Test(org.junit.jupiter.api.Test)

Aggregations

HttpObject (io.netty.handler.codec.http.HttpObject)66 Test (org.junit.Test)38 LastHttpContent (io.netty.handler.codec.http.LastHttpContent)31 HttpContent (io.netty.handler.codec.http.HttpContent)29 FullHttpResponse (io.netty.handler.codec.http.FullHttpResponse)27 DefaultFullHttpResponse (io.netty.handler.codec.http.DefaultFullHttpResponse)25 ArrayList (java.util.ArrayList)19 DefaultFullHttpRequest (io.netty.handler.codec.http.DefaultFullHttpRequest)16 DefaultHttpRequest (io.netty.handler.codec.http.DefaultHttpRequest)14 FullHttpRequest (io.netty.handler.codec.http.FullHttpRequest)14 HttpTrade (org.jocean.http.server.HttpServerBuilder.HttpTrade)14 EmbeddedChannel (io.netty.channel.embedded.EmbeddedChannel)9 DefaultHttpResponse (io.netty.handler.codec.http.DefaultHttpResponse)9 HttpResponse (io.netty.handler.codec.http.HttpResponse)9 Subscription (rx.Subscription)9 Nettys4Test (org.jocean.http.util.Nettys4Test)8 TestSubscriber (rx.observers.TestSubscriber)8 HttpRequest (io.netty.handler.codec.http.HttpRequest)7 DisposableWrapper (org.jocean.idiom.DisposableWrapper)7 Channel (io.netty.channel.Channel)6