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


Java HttpHeaders.entries方法代碼示例

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


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

示例1: getHeaderSize

import io.netty.handler.codec.http.HttpHeaders; //導入方法依賴的package包/類
/**
 * Returns the size of the headers, including the 2 CRLFs at the end of the header block.
 *
 * @param headers headers to size
 * @return length of the headers, in bytes
 */
public static long getHeaderSize(HttpHeaders headers) {
    long headersSize = 0;
    for (Map.Entry<String, String> header : headers.entries()) {
        // +2 for ': ', +2 for new line
        headersSize += header.getKey().length() + header.getValue().length() + 4;
    }
    return headersSize;
}
 
開發者ID:misakuo,項目名稱:Dream-Catcher,代碼行數:15,代碼來源:BrowserMobHttpUtil.java

示例2: captureHeaders

import io.netty.handler.codec.http.HttpHeaders; //導入方法依賴的package包/類
protected void captureHeaders(HttpHeaders headers) {
    Log.e("InnerHandle", "captureHeaders " + harEntry.getId());
    for (Map.Entry<String, String> header : headers.entries()) {
        harRequest.getRequest().getHeaders().add(new HarNameValuePair(header.getKey(), header.getValue()));
        harRequest.addHeader(header.getKey(), header.getValue());
    }
}
 
開發者ID:misakuo,項目名稱:Dream-Catcher,代碼行數:8,代碼來源:HarCaptureFilter.java

示例3: captureResponseHeaders

import io.netty.handler.codec.http.HttpHeaders; //導入方法依賴的package包/類
protected void captureResponseHeaders(HttpResponse httpResponse) {
    Log.e("InnerHandle", "captureResponseHeaders " + harEntry.getId());
    HttpHeaders headers = httpResponse.headers();
    for (Map.Entry<String, String> header : headers.entries()) {
        harResponse.getResponse().getHeaders().add(new HarNameValuePair(header.getKey(), header.getValue()));
        harResponse.addHeader(header.getKey(), header.getValue());
    }
}
 
開發者ID:misakuo,項目名稱:Dream-Catcher,代碼行數:9,代碼來源:HarCaptureFilter.java

示例4: getRequestHash

import io.netty.handler.codec.http.HttpHeaders; //導入方法依賴的package包/類
private String getRequestHash(FullHttpRequest request) {
	HttpHeaders headers = request.headers();
	String requestURI = getRequestURI(request);
	HttpMethod requestMethod = request.getMethod();
	Set<String> skipHeaders = m_skipHeaders;
	boolean skipRequestContent = m_uriMatchEnabled
			&& WildcardMatcher.isPatternCanBeMatchedIn(
					m_uriMatchOnly,
					new CacheDecisionObject(requestURI, requestMethod
							.name()));
	if(skipRequestContent){
		skipHeaders = new HashSet<>(m_skipHeaders);
		skipHeaders.add(HttpHeaders.Names.CONTENT_LENGTH.toUpperCase());
	}

	int uriHashcode = requestURI.hashCode();
	int methodHashCode = requestMethod.hashCode();
	List<Entry<String, String>> entries = headers.entries();
	List<String> hashList = new ArrayList<>();
	for (Iterator<Entry<String, String>> it = entries.iterator(); it
			.hasNext();) {
		Entry<String, String> entry = it.next();
		if (skipHeaders.contains(entry.getKey().toUpperCase())) {
			continue;
		}
		hashList.add(entry.getKey());
		hashList.add(entry.getValue());
	}

	int headersHashcode = hashList.hashCode();

	StringBuilder sb = new StringBuilder(4);
	sb.append(uriHashcode).append(methodHashCode).append(headersHashcode);

	if (!skipRequestContent) {
		ByteBuf content = request.content();
		sb.append(content.hashCode());
	}

	return Checksum.checksum(sb.toString());
}
 
開發者ID:eBay,項目名稱:ServiceCOLDCache,代碼行數:42,代碼來源:RequestKeyGenerator.java

示例5: formget

import io.netty.handler.codec.http.HttpHeaders; //導入方法依賴的package包/類
/**
 * Standard usage of HTTP API in Netty without file Upload (get is not able to achieve File upload
 * due to limitation on request size).
 *
 * @return the list of headers that will be used in every example after
 **/
private static List<Entry<String, String>> formget(
        Bootstrap bootstrap, String host, int port, String get, URI uriSimple) throws Exception {
    // XXX /formget
    // No use of HttpPostRequestEncoder since not a POST
    Channel channel = bootstrap.connect(host, port).sync().channel();

    // Prepare the HTTP request.
    QueryStringEncoder encoder = new QueryStringEncoder(get);
    // add Form attribute
    encoder.addParam("getform", "GET");
    encoder.addParam("info", "first value");
    encoder.addParam("secondinfo", "secondvalue ���&");
    // not the big one since it is not compatible with GET size
    // encoder.addParam("thirdinfo", textArea);
    encoder.addParam("thirdinfo", "third value\r\ntest second line\r\n\r\nnew line\r\n");
    encoder.addParam("Send", "Send");

    URI uriGet = new URI(encoder.toString());
    HttpRequest request = new DefaultHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET, uriGet.toASCIIString());
    HttpHeaders headers = request.headers();
    headers.set(HttpHeaderNames.HOST, host);
    headers.set(HttpHeaderNames.CONNECTION, HttpHeaderValues.CLOSE);
    headers.set(HttpHeaderNames.ACCEPT_ENCODING, HttpHeaderValues.GZIP + "," + HttpHeaderValues.DEFLATE);

    headers.set(HttpHeaderNames.ACCEPT_CHARSET, "ISO-8859-1,utf-8;q=0.7,*;q=0.7");
    headers.set(HttpHeaderNames.ACCEPT_LANGUAGE, "fr");
    headers.set(HttpHeaderNames.REFERER, uriSimple.toString());
    headers.set(HttpHeaderNames.USER_AGENT, "Netty Simple Http Client side");
    headers.set(HttpHeaderNames.ACCEPT, "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8");

    //connection will not close but needed
    // headers.set("Connection","keep-alive");
    // headers.set("Keep-Alive","300");

    headers.set(
            HttpHeaderNames.COOKIE, ClientCookieEncoder.STRICT.encode(
                    new DefaultCookie("my-cookie", "foo"),
                    new DefaultCookie("another-cookie", "bar"))
    );

    // send request
    channel.writeAndFlush(request);

    // Wait for the server to close the connection.
    channel.closeFuture().sync();

    // convert headers to list
    return headers.entries();
}
 
開發者ID:cowthan,項目名稱:JavaAyo,代碼行數:56,代碼來源:HttpUploadClient.java


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