Return-Path: X-Original-To: apmail-hc-commits-archive@www.apache.org Delivered-To: apmail-hc-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 79C2E17C4D for ; Thu, 5 Feb 2015 14:19:48 +0000 (UTC) Received: (qmail 15978 invoked by uid 500); 5 Feb 2015 14:19:43 -0000 Delivered-To: apmail-hc-commits-archive@hc.apache.org Received: (qmail 15877 invoked by uid 500); 5 Feb 2015 14:19:43 -0000 Mailing-List: contact commits-help@hc.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "HttpComponents Project" Delivered-To: mailing list commits@hc.apache.org Received: (qmail 15647 invoked by uid 99); 5 Feb 2015 14:19:43 -0000 Received: from eris.apache.org (HELO hades.apache.org) (140.211.11.105) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 05 Feb 2015 14:19:43 +0000 Received: from hades.apache.org (localhost [127.0.0.1]) by hades.apache.org (ASF Mail Server at hades.apache.org) with ESMTP id 1BEA1AC006E for ; Thu, 5 Feb 2015 14:19:43 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1657573 [7/10] - in /httpcomponents/site: ./ httpcomponents-client-4.3.x/ httpcomponents-client-4.4.x/ httpcomponents-client-4.4.x/fluent-hc/apidocs/org/apache/http/client/fluent/ httpcomponents-client-4.4.x/fluent-hc/apidocs/org/apache/ht... Date: Thu, 05 Feb 2015 14:19:41 -0000 To: commits@hc.apache.org From: olegk@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20150205141943.1BEA1AC006E@hades.apache.org> Added: httpcomponents/site/httpcomponents-client-4.4.x/httpclient/xref/org/apache/http/impl/cookie/LaxExpiresHandler.html URL: http://svn.apache.org/viewvc/httpcomponents/site/httpcomponents-client-4.4.x/httpclient/xref/org/apache/http/impl/cookie/LaxExpiresHandler.html?rev=1657573&view=auto ============================================================================== --- httpcomponents/site/httpcomponents-client-4.4.x/httpclient/xref/org/apache/http/impl/cookie/LaxExpiresHandler.html (added) +++ httpcomponents/site/httpcomponents-client-4.4.x/httpclient/xref/org/apache/http/impl/cookie/LaxExpiresHandler.html Thu Feb 5 14:19:40 2015 @@ -0,0 +1,234 @@ + + + + +LaxExpiresHandler xref + + + +
+
+1   /*
+2    * ====================================================================
+3    * Licensed to the Apache Software Foundation (ASF) under one
+4    * or more contributor license agreements.  See the NOTICE file
+5    * distributed with this work for additional information
+6    * regarding copyright ownership.  The ASF licenses this file
+7    * to you under the Apache License, Version 2.0 (the
+8    * "License"); you may not use this file except in compliance
+9    * with the License.  You may obtain a copy of the License at
+10   *
+11   *   http://www.apache.org/licenses/LICENSE-2.0
+12   *
+13   * Unless required by applicable law or agreed to in writing,
+14   * software distributed under the License is distributed on an
+15   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+16   * KIND, either express or implied.  See the License for the
+17   * specific language governing permissions and limitations
+18   * under the License.
+19   * ====================================================================
+20   *
+21   * This software consists of voluntary contributions made by many
+22   * individuals on behalf of the Apache Software Foundation.  For more
+23   * information on the Apache Software Foundation, please see
+24   * <http://www.apache.org/>.
+25   *
+26   */
+27  package org.apache.http.impl.cookie;
+28  
+29  import java.util.BitSet;
+30  import java.util.Calendar;
+31  import java.util.Locale;
+32  import java.util.Map;
+33  import java.util.TimeZone;
+34  import java.util.concurrent.ConcurrentHashMap;
+35  import java.util.regex.Matcher;
+36  import java.util.regex.Pattern;
+37  
+38  import org.apache.http.annotation.Immutable;
+39  import org.apache.http.cookie.ClientCookie;
+40  import org.apache.http.cookie.CommonCookieAttributeHandler;
+41  import org.apache.http.cookie.MalformedCookieException;
+42  import org.apache.http.cookie.SetCookie;
+43  import org.apache.http.message.ParserCursor;
+44  import org.apache.http.util.Args;
+45  
+46  /**
+47   *
+48   * @since 4.4
+49   */
+50  @Immutable
+51  public class LaxExpiresHandler extends AbstractCookieAttributeHandler implements CommonCookieAttributeHandler {
+52  
+53      static final TimeZone UTC = TimeZone.getTimeZone("UTC");
+54  
+55      private static final BitSet DELIMS;
+56      static {
+57          final BitSet bitSet = new BitSet();
+58          bitSet.set(0x9);
+59          for (int b = 0x20; b <= 0x2f; b++) {
+60              bitSet.set(b);
+61          }
+62          for (int b = 0x3b; b <= 0x40; b++) {
+63              bitSet.set(b);
+64          }
+65          for (int b = 0x5b; b <= 0x60; b++) {
+66              bitSet.set(b);
+67          }
+68          for (int b = 0x7b; b <= 0x7e; b++) {
+69              bitSet.set(b);
+70          }
+71          DELIMS = bitSet;
+72      }
+73      private static final Map<String, Integer> MONTHS;
+74      static {
+75          final ConcurrentHashMap<String, Integer> map = new ConcurrentHashMap<String, Integer>(12);
+76          map.put("jan", Calendar.JANUARY);
+77          map.put("feb", Calendar.FEBRUARY);
+78          map.put("mar", Calendar.MARCH);
+79          map.put("apr", Calendar.APRIL);
+80          map.put("may", Calendar.MAY);
+81          map.put("jun", Calendar.JUNE);
+82          map.put("jul", Calendar.JULY);
+83          map.put("aug", Calendar.AUGUST);
+84          map.put("sep", Calendar.SEPTEMBER);
+85          map.put("oct", Calendar.OCTOBER);
+86          map.put("nov", Calendar.NOVEMBER);
+87          map.put("dec", Calendar.DECEMBER);
+88          MONTHS = map;
+89      }
+90  
+91      private final static Pattern TIME_PATTERN = Pattern.compile(
+92              "^([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})([^0-9].*)?$");
+93      private final static Pattern DAY_OF_MONTH_PATTERN = Pattern.compile(
+94              "^([0-9]{1,2})([^0-9].*)?$");
+95      private final static Pattern MONTH_PATTERN = Pattern.compile(
+96              "^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)(.*)?$", Pattern.CASE_INSENSITIVE);
+97      private final static Pattern YEAR_PATTERN = Pattern.compile(
+98              "^([0-9]{2,4})([^0-9].*)?$");
+99  
+100     public LaxExpiresHandler() {
+101         super();
+102     }
+103 
+104     @Override
+105     public void parse(final SetCookie cookie, final String value) throws MalformedCookieException {
+106         Args.notNull(cookie, "Cookie");
+107         final ParserCursor cursor = new ParserCursor(0, value.length());
+108         final StringBuilder content = new StringBuilder();
+109 
+110         int second = 0, minute = 0, hour = 0, day = 0, month = 0, year = 0;
+111         boolean foundTime = false, foundDayOfMonth = false, foundMonth = false, foundYear = false;
+112         try {
+113             while (!cursor.atEnd()) {
+114                 skipDelims(value, cursor);
+115                 content.setLength(0);
+116                 copyContent(value, cursor, content);
+117 
+118                 if (content.length() == 0) {
+119                     break;
+120                 }
+121                 if (!foundTime) {
+122                     final Matcher matcher = TIME_PATTERN.matcher(content);
+123                     if (matcher.matches()) {
+124                         foundTime = true;
+125                         hour = Integer.parseInt(matcher.group(1));
+126                         minute = Integer.parseInt(matcher.group(2));
+127                         second =Integer.parseInt(matcher.group(3));
+128                         continue;
+129                     }
+130                 }
+131                 if (!foundDayOfMonth) {
+132                     final Matcher matcher = DAY_OF_MONTH_PATTERN.matcher(content);
+133                     if (matcher.matches()) {
+134                         foundDayOfMonth = true;
+135                         day = Integer.parseInt(matcher.group(1));
+136                         continue;
+137                     }
+138                 }
+139                 if (!foundMonth) {
+140                     final Matcher matcher = MONTH_PATTERN.matcher(content);
+141                     if (matcher.matches()) {
+142                         foundMonth = true;
+143                         month = MONTHS.get(matcher.group(1).toLowerCase(Locale.ROOT));
+144                         continue;
+145                     }
+146                 }
+147                 if (!foundYear) {
+148                     final Matcher matcher = YEAR_PATTERN.matcher(content);
+149                     if (matcher.matches()) {
+150                         foundYear = true;
+151                         year = Integer.parseInt(matcher.group(1));
+152                         continue;
+153                     }
+154                 }
+155             }
+156         } catch (NumberFormatException ignore) {
+157             throw new MalformedCookieException("Invalid 'expires' attribute: " + value);
+158         }
+159         if (!foundTime || !foundDayOfMonth || !foundMonth || !foundYear) {
+160             throw new MalformedCookieException("Invalid 'expires' attribute: " + value);
+161         }
+162         if (year >= 70 && year <= 99) {
+163             year = 1900 + year;
+164         }
+165         if (year >= 0 && year <= 69) {
+166             year = 2000 + year;
+167         }
+168         if (day < 1 || day > 31 || year < 1601 || hour > 23 || minute > 59 || second > 59) {
+169             throw new MalformedCookieException("Invalid 'expires' attribute: " + value);
+170         }
+171 
+172         final Calendar c = Calendar.getInstance();
+173         c.setTimeZone(UTC);
+174         c.setTimeInMillis(0L);
+175         c.set(Calendar.SECOND, second);
+176         c.set(Calendar.MINUTE, minute);
+177         c.set(Calendar.HOUR_OF_DAY, hour);
+178         c.set(Calendar.DAY_OF_MONTH, day);
+179         c.set(Calendar.MONTH, month);
+180         c.set(Calendar.YEAR, year);
+181         cookie.setExpiryDate(c.getTime());
+182     }
+183 
+184     private void skipDelims(final CharSequence buf, final ParserCursor cursor) {
+185         int pos = cursor.getPos();
+186         final int indexFrom = cursor.getPos();
+187         final int indexTo = cursor.getUpperBound();
+188         for (int i = indexFrom; i < indexTo; i++) {
+189             final char current = buf.charAt(i);
+190             if (DELIMS.get(current)) {
+191                 pos++;
+192             } else {
+193                 break;
+194             }
+195         }
+196         cursor.updatePos(pos);
+197     }
+198 
+199     private void copyContent(final CharSequence buf, final ParserCursor cursor, final StringBuilder dst) {
+200         int pos = cursor.getPos();
+201         final int indexFrom = cursor.getPos();
+202         final int indexTo = cursor.getUpperBound();
+203         for (int i = indexFrom; i < indexTo; i++) {
+204             final char current = buf.charAt(i);
+205             if (DELIMS.get(current)) {
+206                 break;
+207             } else {
+208                 pos++;
+209                 dst.append(current);
+210             }
+211         }
+212         cursor.updatePos(pos);
+213     }
+214 
+215     @Override
+216     public String getAttributeName() {
+217         return ClientCookie.MAX_AGE_ATTR;
+218     }
+219 
+220 }
+
+
+ + Propchange: httpcomponents/site/httpcomponents-client-4.4.x/httpclient/xref/org/apache/http/impl/cookie/LaxExpiresHandler.html ------------------------------------------------------------------------------ svn:eol-style = native Propchange: httpcomponents/site/httpcomponents-client-4.4.x/httpclient/xref/org/apache/http/impl/cookie/LaxExpiresHandler.html ------------------------------------------------------------------------------ svn:keywords = Date Revision Propchange: httpcomponents/site/httpcomponents-client-4.4.x/httpclient/xref/org/apache/http/impl/cookie/LaxExpiresHandler.html ------------------------------------------------------------------------------ svn:mime-type = text/html Added: httpcomponents/site/httpcomponents-client-4.4.x/httpclient/xref/org/apache/http/impl/cookie/LaxMaxAgeHandler.html URL: http://svn.apache.org/viewvc/httpcomponents/site/httpcomponents-client-4.4.x/httpclient/xref/org/apache/http/impl/cookie/LaxMaxAgeHandler.html?rev=1657573&view=auto ============================================================================== --- httpcomponents/site/httpcomponents-client-4.4.x/httpclient/xref/org/apache/http/impl/cookie/LaxMaxAgeHandler.html (added) +++ httpcomponents/site/httpcomponents-client-4.4.x/httpclient/xref/org/apache/http/impl/cookie/LaxMaxAgeHandler.html Thu Feb 5 14:19:40 2015 @@ -0,0 +1,93 @@ + + + + +LaxMaxAgeHandler xref + + + +
+
+1   /*
+2    * ====================================================================
+3    * Licensed to the Apache Software Foundation (ASF) under one
+4    * or more contributor license agreements.  See the NOTICE file
+5    * distributed with this work for additional information
+6    * regarding copyright ownership.  The ASF licenses this file
+7    * to you under the Apache License, Version 2.0 (the
+8    * "License"); you may not use this file except in compliance
+9    * with the License.  You may obtain a copy of the License at
+10   *
+11   *   http://www.apache.org/licenses/LICENSE-2.0
+12   *
+13   * Unless required by applicable law or agreed to in writing,
+14   * software distributed under the License is distributed on an
+15   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+16   * KIND, either express or implied.  See the License for the
+17   * specific language governing permissions and limitations
+18   * under the License.
+19   * ====================================================================
+20   *
+21   * This software consists of voluntary contributions made by many
+22   * individuals on behalf of the Apache Software Foundation.  For more
+23   * information on the Apache Software Foundation, please see
+24   * <http://www.apache.org/>.
+25   *
+26   */
+27  package org.apache.http.impl.cookie;
+28  
+29  import java.util.Date;
+30  import java.util.regex.Matcher;
+31  import java.util.regex.Pattern;
+32  
+33  import org.apache.http.annotation.Immutable;
+34  import org.apache.http.cookie.ClientCookie;
+35  import org.apache.http.cookie.CommonCookieAttributeHandler;
+36  import org.apache.http.cookie.MalformedCookieException;
+37  import org.apache.http.cookie.SetCookie;
+38  import org.apache.http.util.Args;
+39  import org.apache.http.util.TextUtils;
+40  
+41  /**
+42   *
+43   * @since 4.4
+44   */
+45  @Immutable
+46  public class LaxMaxAgeHandler extends AbstractCookieAttributeHandler implements CommonCookieAttributeHandler {
+47  
+48      private final static Pattern MAX_AGE_PATTERN = Pattern.compile("^\\-?[0-9]+$");
+49  
+50      public LaxMaxAgeHandler() {
+51          super();
+52      }
+53  
+54      @Override
+55      public void parse(final SetCookie cookie, final String value) throws MalformedCookieException {
+56          Args.notNull(cookie, "Cookie");
+57          if (TextUtils.isBlank(value)) {
+58              return;
+59          }
+60          final Matcher matcher = MAX_AGE_PATTERN.matcher(value);
+61          if (matcher.matches()) {
+62              final int age;
+63              try {
+64                  age = Integer.parseInt(value);
+65              } catch (final NumberFormatException e) {
+66                  return;
+67              }
+68              final Date expiryDate = age >= 0 ? new Date(System.currentTimeMillis() + age * 1000L) :
+69                      new Date(Long.MIN_VALUE);
+70              cookie.setExpiryDate(expiryDate);
+71          }
+72      }
+73  
+74      @Override
+75      public String getAttributeName() {
+76          return ClientCookie.MAX_AGE_ATTR;
+77      }
+78  
+79  }
+
+
+ + Propchange: httpcomponents/site/httpcomponents-client-4.4.x/httpclient/xref/org/apache/http/impl/cookie/LaxMaxAgeHandler.html ------------------------------------------------------------------------------ svn:eol-style = native Propchange: httpcomponents/site/httpcomponents-client-4.4.x/httpclient/xref/org/apache/http/impl/cookie/LaxMaxAgeHandler.html ------------------------------------------------------------------------------ svn:keywords = Date Revision Propchange: httpcomponents/site/httpcomponents-client-4.4.x/httpclient/xref/org/apache/http/impl/cookie/LaxMaxAgeHandler.html ------------------------------------------------------------------------------ svn:mime-type = text/html Added: httpcomponents/site/httpcomponents-client-4.4.x/httpclient/xref/org/apache/http/impl/cookie/RFC6265CookieSpecBase.html URL: http://svn.apache.org/viewvc/httpcomponents/site/httpcomponents-client-4.4.x/httpclient/xref/org/apache/http/impl/cookie/RFC6265CookieSpecBase.html?rev=1657573&view=auto ============================================================================== --- httpcomponents/site/httpcomponents-client-4.4.x/httpclient/xref/org/apache/http/impl/cookie/RFC6265CookieSpecBase.html (added) +++ httpcomponents/site/httpcomponents-client-4.4.x/httpclient/xref/org/apache/http/impl/cookie/RFC6265CookieSpecBase.html Thu Feb 5 14:19:40 2015 @@ -0,0 +1,290 @@ + + + + +RFC6265CookieSpecBase xref + + + +
+
+1   /*
+2    * ====================================================================
+3    * Licensed to the Apache Software Foundation (ASF) under one
+4    * or more contributor license agreements.  See the NOTICE file
+5    * distributed with this work for additional information
+6    * regarding copyright ownership.  The ASF licenses this file
+7    * to you under the Apache License, Version 2.0 (the
+8    * "License"); you may not use this file except in compliance
+9    * with the License.  You may obtain a copy of the License at
+10   *
+11   *   http://www.apache.org/licenses/LICENSE-2.0
+12   *
+13   * Unless required by applicable law or agreed to in writing,
+14   * software distributed under the License is distributed on an
+15   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+16   * KIND, either express or implied.  See the License for the
+17   * specific language governing permissions and limitations
+18   * under the License.
+19   * ====================================================================
+20   *
+21   * This software consists of voluntary contributions made by many
+22   * individuals on behalf of the Apache Software Foundation.  For more
+23   * information on the Apache Software Foundation, please see
+24   * <http://www.apache.org/>.
+25   *
+26   */
+27  
+28  package org.apache.http.impl.cookie;
+29  
+30  import java.util.ArrayList;
+31  import java.util.BitSet;
+32  import java.util.Collections;
+33  import java.util.Date;
+34  import java.util.LinkedHashMap;
+35  import java.util.List;
+36  import java.util.Locale;
+37  import java.util.Map;
+38  import java.util.concurrent.ConcurrentHashMap;
+39  
+40  import org.apache.http.FormattedHeader;
+41  import org.apache.http.Header;
+42  import org.apache.http.annotation.ThreadSafe;
+43  import org.apache.http.cookie.ClientCookie;
+44  import org.apache.http.cookie.CommonCookieAttributeHandler;
+45  import org.apache.http.cookie.Cookie;
+46  import org.apache.http.cookie.CookieAttributeHandler;
+47  import org.apache.http.cookie.CookieOrigin;
+48  import org.apache.http.cookie.CookiePriorityComparator;
+49  import org.apache.http.cookie.CookieSpec;
+50  import org.apache.http.cookie.MalformedCookieException;
+51  import org.apache.http.cookie.SM;
+52  import org.apache.http.message.BufferedHeader;
+53  import org.apache.http.message.ParserCursor;
+54  import org.apache.http.message.TokenParser;
+55  import org.apache.http.util.Args;
+56  import org.apache.http.util.CharArrayBuffer;
+57  
+58  /**
+59   * Cookie management functions shared by RFC C6265 compliant specification.
+60   *
+61   * @since 4.4
+62   */
+63  @ThreadSafe
+64  class RFC6265CookieSpecBase implements CookieSpec {
+65  
+66      private final static char PARAM_DELIMITER  = ';';
+67      private final static char COMMA_CHAR       = ',';
+68      private final static char EQUAL_CHAR       = '=';
+69      private final static char DQUOTE_CHAR      = '"';
+70      private final static char ESCAPE_CHAR      = '\\';
+71  
+72      // IMPORTANT!
+73      // These private static variables must be treated as immutable and never exposed outside this class
+74      private static final BitSet TOKEN_DELIMS = TokenParser.INIT_BITSET(EQUAL_CHAR, PARAM_DELIMITER);
+75      private static final BitSet VALUE_DELIMS = TokenParser.INIT_BITSET(PARAM_DELIMITER);
+76      private static final BitSet SPECIAL_CHARS = TokenParser.INIT_BITSET(' ',
+77              DQUOTE_CHAR, COMMA_CHAR, PARAM_DELIMITER, ESCAPE_CHAR);
+78  
+79      private final CookieAttributeHandler[] attribHandlers;
+80      private final Map<String, CookieAttributeHandler> attribHandlerMap;
+81      private final TokenParser tokenParser;
+82  
+83      RFC6265CookieSpecBase(final CommonCookieAttributeHandler... handlers) {
+84          super();
+85          this.attribHandlers = handlers.clone();
+86          this.attribHandlerMap = new ConcurrentHashMap<String, CookieAttributeHandler>(handlers.length);
+87          for (CommonCookieAttributeHandler handler: handlers) {
+88              this.attribHandlerMap.put(handler.getAttributeName().toLowerCase(Locale.ROOT), handler);
+89          }
+90          this.tokenParser = TokenParser.INSTANCE;
+91      }
+92  
+93      static String getDefaultPath(final CookieOrigin origin) {
+94          String defaultPath = origin.getPath();
+95          int lastSlashIndex = defaultPath.lastIndexOf('/');
+96          if (lastSlashIndex >= 0) {
+97              if (lastSlashIndex == 0) {
+98                  //Do not remove the very first slash
+99                  lastSlashIndex = 1;
+100             }
+101             defaultPath = defaultPath.substring(0, lastSlashIndex);
+102         }
+103         return defaultPath;
+104     }
+105 
+106     static String getDefaultDomain(final CookieOrigin origin) {
+107         return origin.getHost();
+108     }
+109 
+110     @Override
+111     public final List<Cookie> parse(final Header header, final CookieOrigin origin) throws MalformedCookieException {
+112         Args.notNull(header, "Header");
+113         Args.notNull(origin, "Cookie origin");
+114         if (!header.getName().equalsIgnoreCase(SM.SET_COOKIE)) {
+115             throw new MalformedCookieException("Unrecognized cookie header: '" + header.toString() + "'");
+116         }
+117         final CharArrayBuffer buffer;
+118         final ParserCursor cursor;
+119         if (header instanceof FormattedHeader) {
+120             buffer = ((FormattedHeader) header).getBuffer();
+121             cursor = new ParserCursor(((FormattedHeader) header).getValuePos(), buffer.length());
+122         } else {
+123             final String s = header.getValue();
+124             if (s == null) {
+125                 throw new MalformedCookieException("Header value is null");
+126             }
+127             buffer = new CharArrayBuffer(s.length());
+128             buffer.append(s);
+129             cursor = new ParserCursor(0, buffer.length());
+130         }
+131         final String name = tokenParser.parseToken(buffer, cursor, TOKEN_DELIMS);
+132         if (name.length() == 0) {
+133             throw new MalformedCookieException("Cookie name is invalid: '" + header.toString() + "'");
+134         }
+135         if (cursor.atEnd()) {
+136             throw new MalformedCookieException("Cookie value is invalid: '" + header.toString() + "'");
+137         }
+138         final int valueDelim = buffer.charAt(cursor.getPos());
+139         cursor.updatePos(cursor.getPos() + 1);
+140         if (valueDelim != '=') {
+141             throw new MalformedCookieException("Cookie value is invalid: '" + header.toString() + "'");
+142         }
+143         final String value = tokenParser.parseValue(buffer, cursor, VALUE_DELIMS);
+144         if (!cursor.atEnd()) {
+145             cursor.updatePos(cursor.getPos() + 1);
+146         }
+147         final BasicClientCookie cookie = new BasicClientCookie(name, value);
+148         cookie.setPath(getDefaultPath(origin));
+149         cookie.setDomain(getDefaultDomain(origin));
+150         cookie.setCreationDate(new Date());
+151 
+152         final Map<String, String> attribMap = new LinkedHashMap<String, String>();
+153         while (!cursor.atEnd()) {
+154             final String paramName = tokenParser.parseToken(buffer, cursor, TOKEN_DELIMS);
+155             String paramValue = null;
+156             if (!cursor.atEnd()) {
+157                 final int paramDelim = buffer.charAt(cursor.getPos());
+158                 cursor.updatePos(cursor.getPos() + 1);
+159                 if (paramDelim == EQUAL_CHAR) {
+160                     paramValue = tokenParser.parseToken(buffer, cursor, VALUE_DELIMS);
+161                     if (!cursor.atEnd()) {
+162                         cursor.updatePos(cursor.getPos() + 1);
+163                     }
+164                 }
+165             }
+166             cookie.setAttribute(paramName.toLowerCase(Locale.ROOT), paramValue);
+167             attribMap.put(paramName, paramValue);
+168         }
+169         // Ignore 'Expires' if 'Max-Age' is present
+170         if (attribMap.containsKey(ClientCookie.MAX_AGE_ATTR)) {
+171             attribMap.remove(ClientCookie.EXPIRES_ATTR);
+172         }
+173 
+174         for (Map.Entry<String, String> entry: attribMap.entrySet()) {
+175             final String paramName = entry.getKey();
+176             final String paramValue = entry.getValue();
+177             final CookieAttributeHandler handler = this.attribHandlerMap.get(paramName);
+178             if (handler != null) {
+179                 handler.parse(cookie, paramValue);
+180             }
+181         }
+182 
+183         return Collections.<Cookie>singletonList(cookie);
+184     }
+185 
+186     @Override
+187     public final void validate(final Cookie cookie, final CookieOrigin origin)
+188             throws MalformedCookieException {
+189         Args.notNull(cookie, "Cookie");
+190         Args.notNull(origin, "Cookie origin");
+191         for (final CookieAttributeHandler handler: this.attribHandlers) {
+192             handler.validate(cookie, origin);
+193         }
+194     }
+195 
+196     @Override
+197     public final boolean match(final Cookie cookie, final CookieOrigin origin) {
+198         Args.notNull(cookie, "Cookie");
+199         Args.notNull(origin, "Cookie origin");
+200         for (final CookieAttributeHandler handler: this.attribHandlers) {
+201             if (!handler.match(cookie, origin)) {
+202                 return false;
+203             }
+204         }
+205         return true;
+206     }
+207 
+208     @Override
+209     public List<Header> formatCookies(final List<Cookie> cookies) {
+210         Args.notEmpty(cookies, "List of cookies");
+211         final List<? extends Cookie> sortedCookies;
+212         if (cookies.size() > 1) {
+213             // Create a mutable copy and sort the copy.
+214             sortedCookies = new ArrayList<Cookie>(cookies);
+215             Collections.sort(sortedCookies, CookiePriorityComparator.INSTANCE);
+216         } else {
+217             sortedCookies = cookies;
+218         }
+219         final CharArrayBuffer buffer = new CharArrayBuffer(20 * sortedCookies.size());
+220         buffer.append(SM.COOKIE);
+221         buffer.append(": ");
+222         for (int n = 0; n < sortedCookies.size(); n++) {
+223             final Cookie cookie = sortedCookies.get(n);
+224             if (n > 0) {
+225                 buffer.append(PARAM_DELIMITER);
+226                 buffer.append(' ');
+227             }
+228             buffer.append(cookie.getName());
+229             final String s = cookie.getValue();
+230             if (s != null) {
+231                 buffer.append(EQUAL_CHAR);
+232                 if (containsSpecialChar(s)) {
+233                     buffer.append(DQUOTE_CHAR);
+234                     for (int i = 0; i < s.length(); i++) {
+235                         final char ch = s.charAt(i);
+236                         if (ch == DQUOTE_CHAR || ch == ESCAPE_CHAR) {
+237                             buffer.append(ESCAPE_CHAR);
+238                         }
+239                         buffer.append(ch);
+240                     }
+241                     buffer.append(DQUOTE_CHAR);
+242                 } else {
+243                     buffer.append(s);
+244                 }
+245             }
+246         }
+247         final List<Header> headers = new ArrayList<Header>(1);
+248         headers.add(new BufferedHeader(buffer));
+249         return headers;
+250     }
+251 
+252     boolean containsSpecialChar(final CharSequence s) {
+253         return containsChars(s, SPECIAL_CHARS);
+254     }
+255 
+256     boolean containsChars(final CharSequence s, final BitSet chars) {
+257         for (int i = 0; i < s.length(); i++) {
+258             final char ch = s.charAt(i);
+259             if (chars.get(ch)) {
+260                 return true;
+261             }
+262         }
+263         return false;
+264     }
+265 
+266     @Override
+267     public final int getVersion() {
+268         return 0;
+269     }
+270 
+271     @Override
+272     public final Header getVersionHeader() {
+273         return null;
+274     }
+275 
+276 }
+
+
+ + Propchange: httpcomponents/site/httpcomponents-client-4.4.x/httpclient/xref/org/apache/http/impl/cookie/RFC6265CookieSpecBase.html ------------------------------------------------------------------------------ svn:eol-style = native Propchange: httpcomponents/site/httpcomponents-client-4.4.x/httpclient/xref/org/apache/http/impl/cookie/RFC6265CookieSpecBase.html ------------------------------------------------------------------------------ svn:keywords = Date Revision Propchange: httpcomponents/site/httpcomponents-client-4.4.x/httpclient/xref/org/apache/http/impl/cookie/RFC6265CookieSpecBase.html ------------------------------------------------------------------------------ svn:mime-type = text/html