• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java ClientCookieEncoder类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中io.netty.handler.codec.http.cookie.ClientCookieEncoder的典型用法代码示例。如果您正苦于以下问题:Java ClientCookieEncoder类的具体用法?Java ClientCookieEncoder怎么用?Java ClientCookieEncoder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ClientCookieEncoder类属于io.netty.handler.codec.http.cookie包,在下文中一共展示了ClientCookieEncoder类的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: extractCookies_works_if_cookies_defined_in_headers

import io.netty.handler.codec.http.cookie.ClientCookieEncoder; //导入依赖的package包/类
@Test
public void extractCookies_works_if_cookies_defined_in_headers() {
    // given
    Cookie cookie1 = new DefaultCookie(UUID.randomUUID().toString(), UUID.randomUUID().toString());
    Cookie cookie2 = new DefaultCookie(UUID.randomUUID().toString(), UUID.randomUUID().toString());
    HttpHeaders headers = new DefaultHttpHeaders().add(HttpHeaders.Names.COOKIE, ClientCookieEncoder.LAX.encode(cookie1, cookie2));

    HttpRequest nettyRequestMock = mock(HttpRequest.class);
    doReturn(headers).when(nettyRequestMock).headers();

    // when
    Set<Cookie> extractedCookies = HttpUtils.extractCookies(nettyRequestMock);

    // then
    assertThat(extractedCookies.contains(cookie1), is(true));
    assertThat(extractedCookies.contains(cookie2), is(true));
}
 
开发者ID:Nike-Inc,项目名称:riposte,代码行数:18,代码来源:HttpUtilsTest.java


示例2: extractCookies_works_if_cookies_defined_in_trailing_headers

import io.netty.handler.codec.http.cookie.ClientCookieEncoder; //导入依赖的package包/类
@Test
public void extractCookies_works_if_cookies_defined_in_trailing_headers() {
    // given
    Cookie cookie1 = new DefaultCookie(UUID.randomUUID().toString(), UUID.randomUUID().toString());
    Cookie cookie2 = new DefaultCookie(UUID.randomUUID().toString(), UUID.randomUUID().toString());
    HttpHeaders trailingHeaders = new DefaultHttpHeaders().add(HttpHeaders.Names.COOKIE, ClientCookieEncoder.LAX.encode(cookie1, cookie2));

    FullHttpRequest nettyRequestMock = mock(FullHttpRequest.class);
    doReturn(new DefaultHttpHeaders()).when(nettyRequestMock).headers();
    doReturn(trailingHeaders).when(nettyRequestMock).trailingHeaders();

    // when
    Set<Cookie> extractedCookies = HttpUtils.extractCookies(nettyRequestMock);

    // then
    assertThat(extractedCookies.contains(cookie1), is(true));
    assertThat(extractedCookies.contains(cookie2), is(true));
}
 
开发者ID:Nike-Inc,项目名称:riposte,代码行数:19,代码来源:HttpUtilsTest.java


示例3: extractCookies_handles_cookie_values_leniently

import io.netty.handler.codec.http.cookie.ClientCookieEncoder; //导入依赖的package包/类
@Test
public void extractCookies_handles_cookie_values_leniently() {
    // given
    //these are cookie values seen in the wild...
    Cookie cookie1 = new DefaultCookie(UUID.randomUUID().toString(), "2094%3Az%7C2021%3Ab");
    Cookie cookie2 = new DefaultCookie(UUID.randomUUID().toString(), "geoloc=cc=US,rc=OR,tp=vhigh,tz=PST,la=45.4978,lo=-122.6937,bw=5000");
    Cookie cookie3 = new DefaultCookie(UUID.randomUUID().toString(), "\"dm=n.com&si=27431295-a282-4745-8cd5-542e7fce" +
            "429e&ss=1477551008358&sl=76&tt=437632&obo=12&sh=1477552753923%3D76%3A12%3A437632%2C1477552698670%3D75%3" +
            "A12%3A429879%2C1477552677137%3D74%3A12%3A426596%2C1477552672564%3D73%3A12%3A425585%2C1477552669893%3D72" +
            "%3A12%3A423456&bcn=%2F%2F3408178b.mpstat.us%2F&ld=1477552753923&r=http%3A%2F%2Fwww.nike.com%2Fbe%2Fde_de%" +
            "2F&ul=1477552756811\"");
    HttpHeaders headers = new DefaultHttpHeaders().add(HttpHeaders.Names.COOKIE, ClientCookieEncoder.LAX.encode(cookie1, cookie2, cookie3));

    HttpRequest nettyRequestMock = mock(HttpRequest.class);
    doReturn(headers).when(nettyRequestMock).headers();

    // when
    Set<Cookie> extractedCookies = HttpUtils.extractCookies(nettyRequestMock);

    // then
    assertThat(extractedCookies.contains(cookie1), is(true));
    assertThat(extractedCookies.contains(cookie2), is(true));
    assertThat(extractedCookies.contains(cookie3), is(true));
}
 
开发者ID:Nike-Inc,项目名称:riposte,代码行数:25,代码来源:HttpUtilsTest.java


示例4: createServerDefault

import io.netty.handler.codec.http.cookie.ClientCookieEncoder; //导入依赖的package包/类
public static HttpResponse createServerDefault(String requestCookie) {
	HttpResponse ret = new HttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.OK, Unpooled.buffer());

	ret.headers().set(HttpHeaderNames.CONTENT_TYPE, "application/json; charset=UTF-8");

	if (requestCookie == null) { return ret; }

	Set<Cookie> cookies = ServerCookieDecoder.STRICT.decode(requestCookie);
	if (cookies.isEmpty()) { return ret; }

	// Reset the cookies if necessary.
	for (Cookie cookie : cookies) {
		ret.headers().add(HttpHeaderNames.SET_COOKIE, ClientCookieEncoder.STRICT.encode(cookie));
	}

	return ret;
}
 
开发者ID:anyflow,项目名称:lannister,代码行数:18,代码来源:HttpResponse.java


示例5: makeEppHttpRequest

import io.netty.handler.codec.http.cookie.ClientCookieEncoder; //导入依赖的package包/类
public static FullHttpRequest makeEppHttpRequest(
    String content,
    String host,
    String path,
    String accessToken,
    String sslClientCertificateHash,
    String serverHostname,
    String clientAddress,
    Cookie... cookies) {
  FullHttpRequest request = makeHttpPostRequest(content, host, path);
  request
      .headers()
      .set(HttpHeaderNames.AUTHORIZATION, "Bearer " + accessToken)
      .set(HttpHeaderNames.CONTENT_TYPE, EPP_CONTENT_TYPE)
      .set(HttpHeaderNames.ACCEPT, EPP_CONTENT_TYPE)
      .set(SSL_CLIENT_CERTIFICATE_HASH_FIELD, sslClientCertificateHash)
      .set(REQUESTED_SERVERNAME_VIA_SNI_FIELD, serverHostname)
      .set(FORWARDED_FOR_FIELD, clientAddress);
  if (cookies.length != 0) {
    request.headers().set(HttpHeaderNames.COOKIE, ClientCookieEncoder.STRICT.encode(cookies));
  }
  return request;
}
 
开发者ID:google,项目名称:nomulus,代码行数:24,代码来源:TestUtils.java


示例6: buildRequestHeaders

import io.netty.handler.codec.http.cookie.ClientCookieEncoder; //导入依赖的package包/类
private void buildRequestHeaders(DefaultFullHttpRequest request) {
    // config request header
    request.headers().set(HttpHeaders.Names.HOST, this.uri.getHost());
    // 添加压缩头
    request.headers().set(HttpHeaders.Names.ACCEPT_ENCODING, "gzip, deflate");
    // added user agent
    if (userAgent != null && !userAgent.isEmpty()) request.headers().set(HttpHeaders.Names.USER_AGENT, userAgent);
    else request.headers().remove(HttpHeaders.Names.USER_AGENT);
    // add custom
    if (this.headers != null) {
        for (Entry<String, String> item : this.headers.entrySet()) {
            request.headers().set(item.getKey(), item.getValue());
        }
    }
    // add cookie
    if (this.cookies != null) {
        String cookieValue = ClientCookieEncoder.STRICT.encode(cookies);
        request.headers().set(HttpHeaders.Names.COOKIE, cookieValue);
    }
}
 
开发者ID:316181444,项目名称:GameServerFramework,代码行数:21,代码来源:NHttpRequestParams.java


示例7: start

import io.netty.handler.codec.http.cookie.ClientCookieEncoder; //导入依赖的package包/类
public void start(final HyperSession parent, WritableByteChannel dest, String chanid, Map<String, Cookie> cookies, long size, long offset, final OperationCallback callback) {
   	this.dest = dest;
   	this.cookies = cookies;
   	this.callback = callback;
   	this.size = size;
   	this.sent = offset;
	
   	this.src = this.allocateChannel(parent, callback);
   	
   	if (this.callback.hasErrors()) {
       	callback.complete();
       	return;
   	}
	
	// send a request to get things going
	
	HttpRequest req = new DefaultHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET, "/download/" + chanid);
	
	req.headers().set(Names.HOST, parent.getInfo().getHost());
	req.headers().set(Names.USER_AGENT, "DivConq HyperAPI Client 1.0");
	req.headers().set(Names.CONNECTION, HttpHeaders.Values.CLOSE);
       req.headers().set(Names.COOKIE, ClientCookieEncoder.STRICT.encode(this.cookies.values()));
       
       // send request
       this.src.writeAndFlush(req);
}
 
开发者ID:Gadreel,项目名称:divconq,代码行数:27,代码来源:DownloadHandler.java


示例8: setup

import io.netty.handler.codec.http.cookie.ClientCookieEncoder; //导入依赖的package包/类
@Before
public void setup() throws Exception {
    s = new Server(conf);
    s.run();

    Connector con = mac.getConnector("root", "secret");
    con.securityOperations().changeUserAuthorizations("root", new Authorizations("A", "B", "C", "D", "E", "F"));

    this.sessionId = UUID.randomUUID().toString();
    AuthCache.getCache().put(sessionId, token);
    group = new NioEventLoopGroup();
    SslContext ssl = SslContextBuilder.forClient().trustManager(InsecureTrustManagerFactory.INSTANCE).build();

    String cookieVal = ClientCookieEncoder.STRICT.encode(Constants.COOKIE_NAME, sessionId);
    HttpHeaders headers = new DefaultHttpHeaders();
    headers.add(Names.COOKIE, cookieVal);

    WebSocketClientHandshaker handshaker = WebSocketClientHandshakerFactory.newHandshaker(LOCATION,
            WebSocketVersion.V13, (String) null, false, headers);
    handler = new ClientHandler(handshaker);
    Bootstrap boot = new Bootstrap();
    boot.group(group).channel(NioSocketChannel.class).handler(new ChannelInitializer<SocketChannel>() {

        @Override
        protected void initChannel(SocketChannel ch) throws Exception {
            ch.pipeline().addLast("ssl", ssl.newHandler(ch.alloc(), "127.0.0.1", WS_PORT));
            ch.pipeline().addLast(new HttpClientCodec());
            ch.pipeline().addLast(new HttpObjectAggregator(8192));
            ch.pipeline().addLast(handler);
        }
    });
    ch = boot.connect("127.0.0.1", WS_PORT).sync().channel();
    // Wait until handshake is complete
    while (!handshaker.isHandshakeComplete()) {
        sleepUninterruptibly(500, TimeUnit.MILLISECONDS);
        LOG.debug("Waiting for Handshake to complete");
    }
}
 
开发者ID:NationalSecurityAgency,项目名称:qonduit,代码行数:39,代码来源:WebSocketIT.java


示例9: normalize

import io.netty.handler.codec.http.cookie.ClientCookieEncoder; //导入依赖的package包/类
protected void normalize() {
	normalizeParameters();

	String encoded = ClientCookieEncoder.STRICT.encode(cookies);
	if (encoded == null) { return; }

	headers().set(HttpHeaderNames.COOKIE, encoded);
}
 
开发者ID:anyflow,项目名称:lannister,代码行数:9,代码来源:HttpRequest.java


示例10: addCookie

import io.netty.handler.codec.http.cookie.ClientCookieEncoder; //导入依赖的package包/类
@Override
public HttpClientRequest addCookie(Cookie cookie) {
	if (!hasSentHeaders()) {
		this.requestHeaders.add(HttpHeaderNames.COOKIE,
				ClientCookieEncoder.STRICT.encode(cookie));
	}
	else {
		throw new IllegalStateException("Status and headers already sent");
	}
	return this;
}
 
开发者ID:reactor,项目名称:reactor-netty,代码行数:12,代码来源:HttpClientOperations.java


示例11: setCookies

import io.netty.handler.codec.http.cookie.ClientCookieEncoder; //导入依赖的package包/类
private void setCookies(HttpRequest request) {
  if (null == cookies || cookies.isEmpty()) {
    return;
  }
  List<Cookie> cookieList = new ArrayList<>(cookies.size());
  for (Map.Entry<String, String> entry : cookies.entrySet()) {
    cookieList.add(new DefaultCookie(entry.getKey(), entry.getValue()));
  }
  request.headers().set(COOKIE, ClientCookieEncoder.STRICT.encode(cookieList));
}
 
开发者ID:orctom,项目名称:laputa,代码行数:11,代码来源:HttpClient.java


示例12: send

import io.netty.handler.codec.http.cookie.ClientCookieEncoder; //导入依赖的package包/类
public void send(Message msg) {
	Logger.debug("Sending message: " + msg);
	
	try {
		if (this.chan != null) {
			if (this.info.getKind() == ConnectorKind.WebSocket)
				this.chan.writeAndFlush(new TextWebSocketFrame(msg.toString()));
			else {
				DefaultFullHttpRequest req = new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.POST, this.info.getPath());
				
				req.headers().set(Names.HOST, this.info.getHost());
				req.headers().set(Names.USER_AGENT, "DivConq HyperAPI Client 1.0");
				req.headers().set(Names.CONNECTION, HttpHeaders.Values.KEEP_ALIVE);
				req.headers().set(Names.CONTENT_ENCODING, "UTF-8");
				req.headers().set(Names.CONTENT_TYPE, "application/json; charset=utf-8");
	            req.headers().set(Names.COOKIE, ClientCookieEncoder.STRICT.encode(this.cookies.values()));
			    
	            // TODO make more efficient - UTF8 encode directly to buffer
	            ByteBuf buf = Unpooled.copiedBuffer(msg.toString(), CharsetUtil.UTF_8);
	            int clen = buf.readableBytes();
	            req.content().writeBytes(buf);
	            buf.release();
	            
	            // Add 'Content-Length' header only for a keep-alive connection.
	            req.headers().set(Names.CONTENT_LENGTH, clen);
				
				this.chan.writeAndFlush(req);
			}
		}
	}
	catch (Exception x) {
		Logger.error("Send HTTP Message error: " + x);
	}
}
 
开发者ID:Gadreel,项目名称:divconq,代码行数:35,代码来源:ClientHandler.java


示例13: getCookieHeader

import io.netty.handler.codec.http.cookie.ClientCookieEncoder; //导入依赖的package包/类
private String getCookieHeader(HttpRequest request) {
    List<Cookie> cookies = new ArrayList<Cookie>();
    for (org.mockserver.model.Cookie cookie : request.getCookieList()) {
        cookies.add(new DefaultCookie(cookie.getName().getValue(), cookie.getValue().getValue()));
    }
    if (cookies.size() > 0) {
        return " -H '" + COOKIE + ": " + ClientCookieEncoder.LAX.encode(cookies) + "'";
    } else {
        return "";
    }
}
 
开发者ID:jamesdbloom,项目名称:mockserver,代码行数:12,代码来源:HttpRequestToCurlSerializer.java


示例14: addCookie

import io.netty.handler.codec.http.cookie.ClientCookieEncoder; //导入依赖的package包/类
private void addCookie(FullHttpRequest request) {
    request.headers().set(Names.COOKIE, ClientCookieEncoder.STRICT.encode(Constants.COOKIE_NAME, cookie));
}
 
开发者ID:NationalSecurityAgency,项目名称:qonduit,代码行数:4,代码来源:HttpRequestDecoderTest.java


示例15: netty_helper_constructor_populates_request_info_appropriately

import io.netty.handler.codec.http.cookie.ClientCookieEncoder; //导入依赖的package包/类
@Test
public void netty_helper_constructor_populates_request_info_appropriately() {
    // given
    String uri = "/some/uri/path/%24foobar%26?foo=bar&secondparam=secondvalue";
    Map<String, List<String>> expectedQueryParamMap = new HashMap<>();
    expectedQueryParamMap.put("foo", Arrays.asList("bar"));
    expectedQueryParamMap.put("secondparam", Arrays.asList("secondvalue"));
    HttpMethod method = HttpMethod.PATCH;
    String cookieName = UUID.randomUUID().toString();
    String cookieValue = UUID.randomUUID().toString();
    String content = UUID.randomUUID().toString();
    byte[] contentBytes = content.getBytes();
    Charset contentCharset = CharsetUtil.UTF_8;
    ByteBuf contentByteBuf = Unpooled.copiedBuffer(contentBytes);
    HttpHeaders headers = new DefaultHttpHeaders()
            .add("header1", "val1")
            .add(HttpHeaders.Names.CONTENT_TYPE, contentCharset)
            .add(HttpHeaders.Names.CONNECTION, HttpHeaders.Values.KEEP_ALIVE)
            .add(HttpHeaders.Names.COOKIE, ClientCookieEncoder.LAX.encode(cookieName, cookieValue));
    HttpHeaders trailingHeaders = new DefaultHttpHeaders().add("trailingHeader1", "trailingVal1");
    HttpVersion protocolVersion = HttpVersion.HTTP_1_1;

    FullHttpRequest nettyRequestMock = mock(FullHttpRequest.class);
    doReturn(uri).when(nettyRequestMock).getUri();
    doReturn(method).when(nettyRequestMock).getMethod();
    doReturn(headers).when(nettyRequestMock).headers();
    doReturn(trailingHeaders).when(nettyRequestMock).trailingHeaders();
    doReturn(contentByteBuf).when(nettyRequestMock).content();
    doReturn(protocolVersion).when(nettyRequestMock).getProtocolVersion();

    // when
    RequestInfoImpl<?> requestInfo = new RequestInfoImpl<>(nettyRequestMock);

    // then
    assertThat("getUri was not the same value sent in", requestInfo.getUri(), is(uri));
    assertThat("getPath did not decode as expected", requestInfo.getPath(), is("/some/uri/path/$foobar&"));
    assertThat(requestInfo.getMethod(), is(method));
    assertThat(requestInfo.getHeaders(), is(headers));
    assertThat(requestInfo.getTrailingHeaders(), is(trailingHeaders));
    assertThat(requestInfo.getQueryParams(), notNullValue());
    assertThat(requestInfo.getQueryParams().parameters(), is(expectedQueryParamMap));
    assertThat(requestInfo.getCookies(), is(Sets.newHashSet(new DefaultCookie(cookieName, cookieValue))));
    assertThat(requestInfo.pathTemplate, nullValue());
    assertThat(requestInfo.pathParams.isEmpty(), is(true));
    assertThat(requestInfo.getRawContentBytes(), is(contentBytes));
    assertThat(requestInfo.getRawContent(), is(content));
    assertThat(requestInfo.content, nullValue());
    assertThat(requestInfo.getContentCharset(), is(contentCharset));
    assertThat(requestInfo.getProtocolVersion(), is(protocolVersion));
    assertThat(requestInfo.isKeepAliveRequested(), is(true));
}
 
开发者ID:Nike-Inc,项目名称:riposte,代码行数:52,代码来源:RequestInfoImplTest.java


示例16: formget

import io.netty.handler.codec.http.cookie.ClientCookieEncoder; //导入依赖的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


示例17: main

import io.netty.handler.codec.http.cookie.ClientCookieEncoder; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
    URI uri = new URI(URL);
    String scheme = uri.getScheme() == null? "http" : uri.getScheme();
    String host = uri.getHost() == null? "127.0.0.1" : uri.getHost();
    int port = uri.getPort();
    if (port == -1) {
        if ("http".equalsIgnoreCase(scheme)) {
            port = 80;
        } else if ("https".equalsIgnoreCase(scheme)) {
            port = 443;
        }
    }

    if (!"http".equalsIgnoreCase(scheme) && !"https".equalsIgnoreCase(scheme)) {
        System.err.println("Only HTTP(S) is supported.");
        return;
    }

    // Configure SSL context if necessary.
    final boolean ssl = "https".equalsIgnoreCase(scheme);
    final SslContext sslCtx;
    if (ssl) {
        sslCtx = SslContextBuilder.forClient()
            .trustManager(InsecureTrustManagerFactory.INSTANCE).build();
    } else {
        sslCtx = null;
    }

    // Configure the client.
    EventLoopGroup group = new NioEventLoopGroup();
    try {
        Bootstrap b = new Bootstrap();
        b.group(group)
         .channel(NioSocketChannel.class)
         .handler(new HttpSnoopClientInitializer(sslCtx));

        // Make the connection attempt.
        Channel ch = b.connect(host, port).sync().channel();

        // Prepare the HTTP request.
        HttpRequest request = new DefaultFullHttpRequest(
                HttpVersion.HTTP_1_1, HttpMethod.GET, uri.getRawPath());
        request.headers().set(HttpHeaderNames.HOST, host);
        request.headers().set(HttpHeaderNames.CONNECTION, HttpHeaderValues.CLOSE);
        request.headers().set(HttpHeaderNames.ACCEPT_ENCODING, HttpHeaderValues.GZIP);

        // Set some example cookies.
        request.headers().set(
                HttpHeaderNames.COOKIE,
                ClientCookieEncoder.STRICT.encode(
                        new DefaultCookie("my-cookie", "foo"),
                        new DefaultCookie("another-cookie", "bar")));

        // Send the HTTP request.
        ch.writeAndFlush(request);

        // Wait for the server to close the connection.
        ch.closeFuture().sync();
    } finally {
        // Shut down executor threads to exit.
        group.shutdownGracefully();
    }
}
 
开发者ID:cowthan,项目名称:JavaAyo,代码行数:64,代码来源:HttpSnoopClient.java


示例18: loadCookies

import io.netty.handler.codec.http.cookie.ClientCookieEncoder; //导入依赖的package包/类
/**
 * Load session cookies in the cookie store and write them in to the HTTP request.
 *
 * <p>Multiple cookies are folded into one {@code Cookie} header per RFC 6265.
 *
 * @see <a href="https://tools.ietf.org/html/rfc6265#section-5.4">RFC 6265 5.4.The Cookie
 *     Header</a>
 */
private void loadCookies(FullHttpRequest request) {
  if (!cookieStore.isEmpty()) {
    request
        .headers()
        .set(HttpHeaderNames.COOKIE, ClientCookieEncoder.STRICT.encode(cookieStore.values()));
  }
}
 
开发者ID:google,项目名称:nomulus,代码行数:16,代码来源:HttpsRelayServiceHandler.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java GuildVoiceJoinEvent类代码示例发布时间:2022-05-22
下一篇:
Java ConverterRegistry类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap