1 /* 2 * Copyright 2014 The Netty Project 3 * 4 * The Netty Project licenses this file to you under the Apache License, 5 * version 2.0 (the "License"); you may not use this file except in compliance 6 * with the License. You may obtain a copy of the License at: 7 * 8 * https://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 * License for the specific language governing permissions and limitations 14 * under the License. 15 */ 16 package io.netty.handler.codec.http; 17 18 import io.netty.handler.codec.http.cookie.ClientCookieDecoder; 19 20 /** 21 * A <a href="https://tools.ietf.org/html/rfc6265">RFC6265</a> compliant cookie encoder to be used client side, 22 * so only name=value pairs are sent. 23 * 24 * User-Agents are not supposed to interpret cookies, so, if present, {@link Cookie#rawValue()} will be used. 25 * Otherwise, {@link Cookie#value()} will be used unquoted. 26 * 27 * Note that multiple cookies are supposed to be sent at once in a single "Cookie" header. 28 * 29 * <pre> 30 * // Example 31 * {@link HttpRequest} req = ...; 32 * res.setHeader("Cookie", {@link ClientCookieEncoder}.encode("JSESSIONID", "1234")); 33 * </pre> 34 * 35 * @see ClientCookieDecoder 36 */ 37 @Deprecated 38 public final class ClientCookieEncoder { 39 40 /** 41 * Encodes the specified cookie into a Cookie header value. 42 * 43 * @param name the cookie name 44 * @param value the cookie value 45 * @return a Rfc6265 style Cookie header value 46 */ 47 @Deprecated 48 public static String encode(String name, String value) { 49 return io.netty.handler.codec.http.cookie.ClientCookieEncoder.LAX.encode(name, value); 50 } 51 52 /** 53 * Encodes the specified cookie into a Cookie header value. 54 * 55 * @param cookie the specified cookie 56 * @return a Rfc6265 style Cookie header value 57 */ 58 @Deprecated 59 public static String encode(Cookie cookie) { 60 return io.netty.handler.codec.http.cookie.ClientCookieEncoder.LAX.encode(cookie); 61 } 62 63 /** 64 * Encodes the specified cookies into a single Cookie header value. 65 * 66 * @param cookies some cookies 67 * @return a Rfc6265 style Cookie header value, null if no cookies are passed. 68 */ 69 @Deprecated 70 public static String encode(Cookie... cookies) { 71 return io.netty.handler.codec.http.cookie.ClientCookieEncoder.LAX.encode(cookies); 72 } 73 74 /** 75 * Encodes the specified cookies into a single Cookie header value. 76 * 77 * @param cookies some cookies 78 * @return a Rfc6265 style Cookie header value, null if no cookies are passed. 79 */ 80 @Deprecated 81 public static String encode(Iterable<Cookie> cookies) { 82 return io.netty.handler.codec.http.cookie.ClientCookieEncoder.LAX.encode(cookies); 83 } 84 85 private ClientCookieEncoder() { 86 // unused 87 } 88 }