當前位置: 首頁>>代碼示例>>Java>>正文


Java HttpServerRequest.endHandler方法代碼示例

本文整理匯總了Java中io.vertx.core.http.HttpServerRequest.endHandler方法的典型用法代碼示例。如果您正苦於以下問題:Java HttpServerRequest.endHandler方法的具體用法?Java HttpServerRequest.endHandler怎麽用?Java HttpServerRequest.endHandler使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在io.vertx.core.http.HttpServerRequest的用法示例。


在下文中一共展示了HttpServerRequest.endHandler方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: handle

import io.vertx.core.http.HttpServerRequest; //導入方法依賴的package包/類
@Override
public void handle(RoutingContext context) {
  HttpServerRequest request = context.request();
  // we need to keep state since we can be called again on reroute
  Boolean handled = context.get(BODY_HANDLED);
  if (handled == null || !handled) {
    BHandler handler = new BHandler(context);
    request.handler(handler);
    request.endHandler(v -> handler.end());
    context.put(BODY_HANDLED, true);
  } else {
    // on reroute we need to re-merge the form params if that was desired
    if (mergeFormAttributes && request.isExpectMultipart()) {
      request.params().addAll(request.formAttributes());
    }

    context.next();
  }
}
 
開發者ID:apache,項目名稱:incubator-servicecomb-java-chassis,代碼行數:20,代碼來源:RestBodyHandler.java

示例2: proxyUserRequest

import io.vertx.core.http.HttpServerRequest; //導入方法依賴的package包/類
/**
 * Proxies the specified HTTP request, enriching its headers with authentication information.
 *
 * @param userId  the ID of the user making the request.
 * @param origReq the original request (i.e., {@link RoutingContext#request()}.
 * @param origRes the original response (i.e., {@link RoutingContext#request()}.
 */
public void proxyUserRequest(final String userId,
                             final HttpServerRequest origReq,
                             final HttpServerResponse origRes) {
    final Handler<HttpClientResponse> proxiedResHandler = proxiedRes -> {
        origRes.setChunked(true);
        origRes.setStatusCode(proxiedRes.statusCode());
        origRes.headers().setAll(proxiedRes.headers());
        proxiedRes.handler(origRes::write);
        proxiedRes.endHandler(v -> origRes.end());
    };

    final HttpClientRequest proxiedReq;
    proxiedReq = httpClient.request(origReq.method(), port, host, origReq.uri(), proxiedResHandler);
    proxiedReq.setChunked(true);
    proxiedReq.headers().add(X_FORWARDED_PROTO, getHeader(origReq, X_FORWARDED_PROTO, origReq.scheme()));
    proxiedReq.headers().add(X_FORWARDED_FOR, getHeader(origReq, X_FORWARDED_FOR, origReq.remoteAddress().host()));
    proxiedReq.headers().addAll(origReq.headers());
    injectRutHeader(proxiedReq, userId);
    origReq.handler(proxiedReq::write);
    origReq.endHandler(v -> proxiedReq.end());
}
 
開發者ID:travelaudience,項目名稱:nexus-proxy,代碼行數:29,代碼來源:NexusHttpProxy.java

示例3: 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();

}
 
開發者ID:trajano,項目名稱:app-ms,代碼行數:43,代碼來源:UnprotectedHandler.java


注:本文中的io.vertx.core.http.HttpServerRequest.endHandler方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。