本文整理匯總了Java中io.vertx.core.http.HttpServerRequest.setExpectMultipart方法的典型用法代碼示例。如果您正苦於以下問題:Java HttpServerRequest.setExpectMultipart方法的具體用法?Java HttpServerRequest.setExpectMultipart怎麽用?Java HttpServerRequest.setExpectMultipart使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類io.vertx.core.http.HttpServerRequest
的用法示例。
在下文中一共展示了HttpServerRequest.setExpectMultipart方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: handle
import io.vertx.core.http.HttpServerRequest; //導入方法依賴的package包/類
@Override
public void handle(final RoutingContext context) {
// if null or it is marked as protected then go on.
final PathContext pathContext = PathContext.get(context);
if (pathContext == null) {
context.next();
return;
}
LOG.debug("Handling {} with from={} to={} protected={} ended={}", context, pathContext.getFrom(), pathContext.getTo(), pathContext.isProtected(), context.request().isEnded());
final HttpServerRequest contextRequest = context.request();
contextRequest.setExpectMultipart(context.parsedHeaders().contentType().isPermitted() && "multipart".equals(context.parsedHeaders().contentType().component()));
final RequestOptions clientRequestOptions = Conversions.toRequestOptions(pathContext.getTo(), contextRequest.uri().substring(pathContext.getFrom().length()));
final HttpClientRequest clientRequest = httpClient
.request(contextRequest.method(), clientRequestOptions, clientResponse -> {
contextRequest.response().setChunked(clientResponse.getHeader(HttpHeaders.CONTENT_LENGTH) == null)
.setStatusCode(clientResponse.statusCode());
clientResponse.headers().forEach(e -> contextRequest.response().putHeader(e.getKey(), e.getValue()));
clientResponse.endHandler(v -> contextRequest.response().end());
Pump.pump(clientResponse, contextRequest.response()).start();
}).exceptionHandler(context::fail)
.setChunked(true);
StreamSupport.stream(contextRequest.headers().spliterator(), false)
.filter(Predicates.HEADER_FORWARDABLE)
.forEach(e -> clientRequest.putHeader(e.getKey(), e.getValue()));
clientRequest.putHeader(REQUEST_ID, (String) context.get(REQUEST_ID));
clientRequest.putHeader(DATE, RFC_1123_DATE_TIME.format(now(UTC)));
final Map<String, String> additionalHeaders = context.get("additional_headers");
if (additionalHeaders != null) {
additionalHeaders.forEach(clientRequest::putHeader);
}
contextRequest.endHandler(v -> clientRequest.end());
Pump.pump(contextRequest, clientRequest).start();
contextRequest.resume();
}