/** * Creates a new HTTP request that can be used to stream an arbitrary number of {@link HttpObject} * with the initial {@link HttpHeaders} of the specified {@link HttpMethod} and {@code path}. */ static HttpRequestWriter streaming(HttpMethod method, String path) { requireNonNull(method, "method"); requireNonNull(path, "path"); return streaming(HttpHeaders.of(method, path)); }
@Override public <I, O> ClientCall<I, O> newCall( MethodDescriptor<I, O> method, CallOptions callOptions) { final HttpRequestWriter req = HttpRequest.streaming( HttpHeaders.of(HttpMethod.POST, uri().getPath() + method.getFullMethodName()) .contentType(serializationFormat.mediaType())); final ClientRequestContext ctx = newContext(HttpMethod.POST, req); ctx.logBuilder().serializationFormat(serializationFormat); ctx.logBuilder().deferRequestContent(); ctx.logBuilder().deferResponseContent(); return new ArmeriaClientCall<>( ctx, httpClient, req, method, options().getOrElse(GrpcClientOptions.MAX_OUTBOUND_MESSAGE_SIZE_BYTES, ArmeriaMessageFramer.NO_MAX_OUTBOUND_MESSAGE_SIZE), options().getOrElse( GrpcClientOptions.MAX_INBOUND_MESSAGE_SIZE_BYTES, options().getOrElse( ClientOption.DEFAULT_MAX_RESPONSE_LENGTH, (long) DEFAULT_MAX_INBOUND_MESSAGE_SIZE).intValue()), callOptions, CompressorRegistry.getDefaultInstance(), DecompressorRegistry.getDefaultInstance(), serializationFormat, jsonMarshaller, options().getOrElse(GrpcClientOptions.UNSAFE_WRAP_RESPONSE_BUFFERS, false), advertisedEncodingsHeader); }
private static void invoke0(THttpService service, HttpData content, CompletableFuture<HttpData> promise) throws Exception { final HttpRequestWriter req = HttpRequest.streaming(HttpHeaders.of(HttpMethod.POST, "/")); req.write(content); req.close(); final ServiceRequestContext ctx = ServiceRequestContextBuilder.of(req) .eventLoop(eventLoop.get()) .serverConfigurator(builder -> { builder.blockingTaskExecutor(ImmediateEventExecutor.INSTANCE); builder.verboseResponses(true); }) .build(); final HttpResponse res = service.serve(ctx, req); res.aggregate().handle(voidFunction((aReq, cause) -> { if (cause == null) { if (aReq.headers().status().code() == 200) { promise.complete(aReq.content()); } else { promise.completeExceptionally(new AssertionError( aReq.headers().status() + ", " + aReq.content().toString(StandardCharsets.UTF_8))); } } else { promise.completeExceptionally(cause); } })).exceptionally(CompletionActions::log); }
@Override public <I, O> ClientCall<I, O> newCall( MethodDescriptor<I, O> method, CallOptions callOptions) { final HttpRequestWriter req = HttpRequest.streaming( HttpHeaders.of(HttpMethod.POST, uri().getPath() + method.getFullMethodName()) .contentType(serializationFormat.mediaType())); final ClientRequestContext ctx = newContext(HttpMethod.POST, req); ctx.logBuilder().serializationFormat(serializationFormat); ctx.logBuilder().deferRequestContent(); ctx.logBuilder().deferResponseContent(); return new ArmeriaClientCall<>( ctx, httpClient, req, method, options().getOrElse(GrpcClientOptions.MAX_OUTBOUND_MESSAGE_SIZE_BYTES, ArmeriaMessageFramer.NO_MAX_OUTBOUND_MESSAGE_SIZE), options().getOrElse( GrpcClientOptions.MAX_INBOUND_MESSAGE_SIZE_BYTES, options().getOrElse( ClientOption.DEFAULT_MAX_RESPONSE_LENGTH, (long) DEFAULT_MAX_INBOUND_MESSAGE_SIZE).intValue()), callOptions, CompressorRegistry.getDefaultInstance(), DecompressorRegistry.getDefaultInstance(), serializationFormat, jsonMarshaller, options().getOrElse(GrpcClientOptions.UNSAFE_WRAP_RESPONSE_BUFFERS, false), advertisedEncodingsHeader); }