/** * Default constructor * */ public RFC2965Spec() { super(); this.formatter = new ParameterFormatter(); this.formatter.setAlwaysUseQuotes(true); this.attribHandlerMap = new HashMap(10); this.attribHandlerList = new ArrayList(10); this.rfc2109 = new RFC2109Spec(); registerAttribHandler(Cookie2.PATH, new Cookie2PathAttributeHandler()); registerAttribHandler(Cookie2.DOMAIN, new Cookie2DomainAttributeHandler()); registerAttribHandler(Cookie2.PORT, new Cookie2PortAttributeHandler()); registerAttribHandler(Cookie2.MAXAGE, new Cookie2MaxageAttributeHandler()); registerAttribHandler(Cookie2.SECURE, new CookieSecureAttributeHandler()); registerAttribHandler(Cookie2.COMMENT, new CookieCommentAttributeHandler()); registerAttribHandler(Cookie2.COMMENTURL, new CookieCommentUrlAttributeHandler()); registerAttribHandler(Cookie2.DISCARD, new CookieDiscardAttributeHandler()); registerAttribHandler(Cookie2.VERSION, new Cookie2VersionAttributeHandler()); }
public void testBasicValueFormatting() throws Exception { ParameterFormatter formatter = new ParameterFormatter(); NameValuePair param1 = new NameValuePair("param", "regular_stuff"); NameValuePair param2 = new NameValuePair("param", "this\\that"); NameValuePair param3 = new NameValuePair("param", "this,that"); NameValuePair param4 = new NameValuePair("param", "quote marks (\") must be escaped"); NameValuePair param5 = new NameValuePair("param", "back slash (\\) must be escaped too"); NameValuePair param6 = new NameValuePair("param", "values with\tblanks must always be quoted"); formatter.setAlwaysUseQuotes(false); assertEquals("param=regular_stuff", formatter.format(param1)); assertEquals("param=\"this\\\\that\"", formatter.format(param2)); assertEquals("param=\"this,that\"", formatter.format(param3)); assertEquals("param=\"quote marks (\\\") must be escaped\"", formatter.format(param4)); assertEquals("param=\"back slash (\\\\) must be escaped too\"", formatter.format(param5)); assertEquals("param=\"values with\tblanks must always be quoted\"", formatter.format(param6)); formatter.setAlwaysUseQuotes(true); assertEquals("param=\"regular_stuff\"", formatter.format(param1)); assertEquals("param=\"this\\\\that\"", formatter.format(param2)); assertEquals("param=\"this,that\"", formatter.format(param3)); assertEquals("param=\"quote marks (\\\") must be escaped\"", formatter.format(param4)); assertEquals("param=\"back slash (\\\\) must be escaped too\"", formatter.format(param5)); assertEquals("param=\"values with\tblanks must always be quoted\"", formatter.format(param6)); }
public Header getVersionHeader() { ParameterFormatter formatter = new ParameterFormatter(); StringBuffer buffer = new StringBuffer(); formatter.format(buffer, new NameValuePair("$Version", Integer.toString(getVersion()))); return new Header("Cookie2", buffer.toString(), true); }
/** Default constructor */ public RFC2109Spec() { super(); this.formatter = new ParameterFormatter(); this.formatter.setAlwaysUseQuotes(true); }
/** * Default constructor for the digest authetication scheme. * * @since 3.0 */ public DigestScheme() { super(); this.complete = false; this.formatter = new ParameterFormatter(); }