当前位置: 首页>>代码示例>>Java>>正文


Java HttpServerResponse.setChunked方法代码示例

本文整理汇总了Java中io.vertx.core.http.HttpServerResponse.setChunked方法的典型用法代码示例。如果您正苦于以下问题:Java HttpServerResponse.setChunked方法的具体用法?Java HttpServerResponse.setChunked怎么用?Java HttpServerResponse.setChunked使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在io.vertx.core.http.HttpServerResponse的用法示例。


在下文中一共展示了HttpServerResponse.setChunked方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: proxyUserRequest

import io.vertx.core.http.HttpServerResponse; //导入方法依赖的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

示例2: addChunkedIfNeeded

import io.vertx.core.http.HttpServerResponse; //导入方法依赖的package包/类
private void addChunkedIfNeeded() {

        if (stream instanceof HttpServerResponse) {
            final HttpServerResponse resp = (HttpServerResponse) stream;
            if (resp.headers().get(HttpHeaders.CONTENT_LENGTH) == null) {
                resp.setChunked(true);
            }
        } else if (stream instanceof HttpClientRequest) {
            final HttpClientRequest req = (HttpClientRequest) stream;
            if (req.headers().get(HttpHeaders.CONTENT_LENGTH) == null) {
                req.setChunked(true);
            }
        }

    }
 
开发者ID:trajano,项目名称:app-ms,代码行数:16,代码来源:VertxOutputStream.java

示例3: handle

import io.vertx.core.http.HttpServerResponse; //导入方法依赖的package包/类
public void handle(HttpServerRequest clientRequest, HttpServerResponse clientResponse,
			HttpResponse<Buffer> appResponse) {

		int statusCode = appResponse.statusCode();
		clientResponse.setStatusCode(statusCode);
//		clientResponse.setStatusMessage(appResponse.statusMessage());
//		System.out.println(appResponse.statusMessage());

		MultiMap appHeaders = appResponse.headers();
		appHeaders.forEach(entry -> {
			String k = entry.getKey();
			String v = entry.getValue();
//			System.out.println("Header Response:[" + k + "]=" + v);
			if ("Location".equalsIgnoreCase(k) && S.isNotBlank(v)) {
				String schemal = clientRequest.scheme();
				String host = clientRequest.host();
				clientResponse.putHeader("Location", v.replaceAll(HTTP_SCHEMAL_HOST_REG, schemal + "://" + host + "/"));
			} else
				clientResponse.putHeader(k, v);
		});
		
			

		clientResponse.setChunked(true);
		
		Buffer buff = appResponse.bodyAsBuffer();
		if (buff != null && buff.length() > 0)
			clientResponse.write(buff);

	}
 
开发者ID:troopson,项目名称:etagate,代码行数:31,代码来源:RequestHandler.java


注:本文中的io.vertx.core.http.HttpServerResponse.setChunked方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。