use of io.netty.handler.codec.http.HttpObject in project jocean-http by isdom.
the class RxNettysTestCase method test_BUILD_FULL_REQUEST_WhenNoRequest.
@Test
public final void test_BUILD_FULL_REQUEST_WhenNoRequest() {
final HttpContent[] req_contents = Nettys4Test.buildContentArray(REQ_CONTENT.getBytes(Charsets.UTF_8), 1);
final List<HttpObject> reqs = new ArrayList<HttpObject>() {
private static final long serialVersionUID = 1L;
{
this.addAll(Arrays.asList(req_contents));
this.add(LastHttpContent.EMPTY_LAST_CONTENT);
}
};
final FullHttpRequest fullreq = RxNettys.BUILD_FULL_REQUEST.call(reqs.toArray(new HttpObject[0]));
assertNull(fullreq);
}
use of io.netty.handler.codec.http.HttpObject in project jocean-http by isdom.
the class TestHttpUtil method buildByteBufResponse.
public static Observable<HttpObject> buildByteBufResponse(final String contentType, final ByteBuf content) {
final FullHttpResponse response = new DefaultFullHttpResponse(HttpVersion.HTTP_1_1, OK, content);
response.headers().set(HttpHeaderNames.CONTENT_TYPE, contentType);
response.headers().set(HttpHeaderNames.CONTENT_LENGTH, response.content().readableBytes());
return Observable.<HttpObject>just(response);
}
use of io.netty.handler.codec.http.HttpObject in project jocean-http by isdom.
the class DefaultHttpTradeTestCase method testTradeForCompleteRoundWithMultiContentRequest.
@Test
public final void testTradeForCompleteRoundWithMultiContentRequest() {
final DefaultHttpRequest request = new DefaultHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.POST, "/");
final HttpContent[] req_contents = Nettys4Test.buildContentArray(REQ_CONTENT.getBytes(Charsets.UTF_8), 1);
final EmbeddedChannel channel = new EmbeddedChannel();
final HttpTrade trade = new DefaultHttpTrade(channel);
Observable.<HttpObject>concat(Observable.<HttpObject>just(request), Observable.<HttpObject>from(req_contents), Observable.<HttpObject>just(LastHttpContent.EMPTY_LAST_CONTENT)).subscribe(obj -> writeToInboundAndFlush(channel, obj));
// new Action1<HttpObject>() {
// @Override
// public void call(final HttpObject obj) {
// writeToInboundAndFlush(channel, obj);
// }}
assertTrue(trade.isActive());
final FullHttpResponse response = new DefaultFullHttpResponse(HTTP_1_1, OK);
trade.outbound(Observable.<HttpObject>just(response));
assertFalse(trade.isActive());
}
use of io.netty.handler.codec.http.HttpObject in project jocean-http by isdom.
the class RxNettys method response200OK.
public static Observable<HttpObject> response200OK(final HttpVersion version) {
final HttpResponse response = new DefaultFullHttpResponse(version, HttpResponseStatus.OK);
response.headers().set(HttpHeaderNames.CONTENT_LENGTH, 0);
return Observable.<HttpObject>just(response);
}
use of io.netty.handler.codec.http.HttpObject in project jocean-http by isdom.
the class RxNettys method response401Unauthorized.
public static Observable<HttpObject> response401Unauthorized(final HttpVersion version, final String vlaueOfWWWAuthenticate) {
final HttpResponse response = new DefaultFullHttpResponse(version, HttpResponseStatus.UNAUTHORIZED);
response.headers().set(HttpHeaderNames.WWW_AUTHENTICATE, vlaueOfWWWAuthenticate);
response.headers().set(HttpHeaderNames.CONTENT_LENGTH, 0);
return Observable.<HttpObject>just(response);
}
Aggregations