You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hc.apache.org by ol...@apache.org on 2010/04/23 21:19:31 UTC
svn commit: r937479 [8/12] - in /httpcomponents/httpclient/trunk:
httpclient-benchmark/src/main/java/org/apache/http/client/benchmark/
httpclient-contrib/src/main/java/org/apache/http/contrib/auth/
httpclient/src/main/java/org/apache/http/auth/ httpcli...
Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/BestMatchSpec.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/BestMatchSpec.java?rev=937479&r1=937478&r2=937479&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/BestMatchSpec.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/BestMatchSpec.java Fri Apr 23 19:19:23 2010
@@ -23,7 +23,7 @@
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
- */
+ */
package org.apache.http.impl.cookie;
@@ -41,7 +41,7 @@ import org.apache.http.cookie.SM;
import org.apache.http.cookie.SetCookie2;
/**
- * 'Meta' cookie specification that picks up a cookie policy based on
+ * 'Meta' cookie specification that picks up a cookie policy based on
* the format of cookies sent with the HTTP response.
*
* @since 4.0
@@ -51,7 +51,7 @@ public class BestMatchSpec implements Co
private final String[] datepatterns;
private final boolean oneHeader;
-
+
// Cached values of CookieSpec instances
private RFC2965Spec strict; // @NotThreadSafe
private RFC2109Spec obsoleteStrict; // @NotThreadSafe
@@ -97,7 +97,7 @@ public class BestMatchSpec implements Co
}
public List<Cookie> parse(
- final Header header,
+ final Header header,
final CookieOrigin origin) throws MalformedCookieException {
if (header == null) {
throw new IllegalArgumentException("Header may not be null");
@@ -134,7 +134,7 @@ public class BestMatchSpec implements Co
}
public void validate(
- final Cookie cookie,
+ final Cookie cookie,
final CookieOrigin origin) throws MalformedCookieException {
if (cookie == null) {
throw new IllegalArgumentException("Cookie may not be null");
@@ -176,7 +176,7 @@ public class BestMatchSpec implements Co
throw new IllegalArgumentException("List of cookie may not be null");
}
int version = Integer.MAX_VALUE;
- boolean isSetCookie2 = true;
+ boolean isSetCookie2 = true;
for (Cookie cookie: cookies) {
if (!(cookie instanceof SetCookie2)) {
isSetCookie2 = false;
@@ -208,5 +208,5 @@ public class BestMatchSpec implements Co
public String toString() {
return "best-match";
}
-
+
}
\ No newline at end of file
Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/BestMatchSpecFactory.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/BestMatchSpecFactory.java?rev=937479&r1=937478&r2=937479&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/BestMatchSpecFactory.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/BestMatchSpecFactory.java Fri Apr 23 19:19:23 2010
@@ -40,8 +40,8 @@ import org.apache.http.params.HttpParams
* {@link CookieSpecFactory} implementation that creates and initializes
* {@link BestMatchSpec} instances.
* <p>
- * The following parameters can be used to customize the behavior of this
- * class:
+ * The following parameters can be used to customize the behavior of this
+ * class:
* <ul>
* <li>{@link org.apache.http.cookie.params.CookieSpecPNames#DATE_PATTERNS}</li>
* <li>{@link org.apache.http.cookie.params.CookieSpecPNames#SINGLE_COOKIE_HEADER}</li>
@@ -50,11 +50,11 @@ import org.apache.http.params.HttpParams
* @since 4.0
*/
@Immutable
-public class BestMatchSpecFactory implements CookieSpecFactory {
+public class BestMatchSpecFactory implements CookieSpecFactory {
public CookieSpec newInstance(final HttpParams params) {
if (params != null) {
-
+
String[] patterns = null;
Collection<?> param = (Collection<?>) params.getParameter(
CookieSpecPNames.DATE_PATTERNS);
@@ -64,7 +64,7 @@ public class BestMatchSpecFactory implem
}
boolean singleHeader = params.getBooleanParameter(
CookieSpecPNames.SINGLE_COOKIE_HEADER, false);
-
+
return new BestMatchSpec(patterns, singleHeader);
} else {
return new BestMatchSpec();
Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/BrowserCompatSpec.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/BrowserCompatSpec.java?rev=937479&r1=937478&r2=937479&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/BrowserCompatSpec.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/BrowserCompatSpec.java Fri Apr 23 19:19:23 2010
@@ -23,7 +23,7 @@
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
- */
+ */
package org.apache.http.impl.cookie;
@@ -46,16 +46,16 @@ import org.apache.http.message.ParserCur
import org.apache.http.util.CharArrayBuffer;
/**
- * Cookie specification that strives to closely mimic (mis)behavior of
+ * Cookie specification that strives to closely mimic (mis)behavior of
* common web browser applications such as Microsoft Internet Explorer
* and Mozilla FireFox.
*
- *
- * @since 4.0
+ *
+ * @since 4.0
*/
@NotThreadSafe // superclass is @NotThreadSafe
public class BrowserCompatSpec extends CookieSpecBase {
-
+
@Deprecated
protected static final String[] DATE_PATTERNS = new String[] {
DateUtils.PATTERN_RFC1123,
@@ -71,7 +71,7 @@ public class BrowserCompatSpec extends C
"EEE dd MMM yy HH:mm:ss z",
"EEE,dd-MMM-yy HH:mm:ss z",
"EEE,dd-MMM-yyyy HH:mm:ss z",
- "EEE, dd-MM-yyyy HH:mm:ss z",
+ "EEE, dd-MM-yyyy HH:mm:ss z",
};
private static final String[] DEFAULT_DATE_PATTERNS = new String[] {
@@ -88,11 +88,11 @@ public class BrowserCompatSpec extends C
"EEE dd MMM yy HH:mm:ss z",
"EEE,dd-MMM-yy HH:mm:ss z",
"EEE,dd-MMM-yyyy HH:mm:ss z",
- "EEE, dd-MM-yyyy HH:mm:ss z",
+ "EEE, dd-MM-yyyy HH:mm:ss z",
};
-
- private final String[] datepatterns;
-
+
+ private final String[] datepatterns;
+
/** Default constructor */
public BrowserCompatSpec(final String[] datepatterns) {
super();
@@ -114,8 +114,8 @@ public class BrowserCompatSpec extends C
public BrowserCompatSpec() {
this(null);
}
-
- public List<Cookie> parse(final Header header, final CookieOrigin origin)
+
+ public List<Cookie> parse(final Header header, final CookieOrigin origin)
throws MalformedCookieException {
if (header == null) {
throw new IllegalArgumentException("Header may not be null");
@@ -129,17 +129,17 @@ public class BrowserCompatSpec extends C
throw new MalformedCookieException("Unrecognized cookie header '"
+ header.toString() + "'");
}
- boolean isNetscapeCookie = false;
+ boolean isNetscapeCookie = false;
int i1 = headervalue.toLowerCase(Locale.ENGLISH).indexOf("expires=");
if (i1 != -1) {
i1 += "expires=".length();
int i2 = headervalue.indexOf(';', i1);
if (i2 == -1) {
- i2 = headervalue.length();
+ i2 = headervalue.length();
}
try {
DateUtils.parseDate(headervalue.substring(i1, i2), this.datepatterns);
- isNetscapeCookie = true;
+ isNetscapeCookie = true;
} catch (DateParseException e) {
// Does not look like a valid expiry date
}
@@ -152,7 +152,7 @@ public class BrowserCompatSpec extends C
if (header instanceof FormattedHeader) {
buffer = ((FormattedHeader) header).getBuffer();
cursor = new ParserCursor(
- ((FormattedHeader) header).getValuePos(),
+ ((FormattedHeader) header).getValuePos(),
buffer.length());
} else {
String s = header.getValue();
@@ -209,5 +209,5 @@ public class BrowserCompatSpec extends C
public String toString() {
return "compatibility";
}
-
+
}
Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/BrowserCompatSpecFactory.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/BrowserCompatSpecFactory.java?rev=937479&r1=937478&r2=937479&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/BrowserCompatSpecFactory.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/BrowserCompatSpecFactory.java Fri Apr 23 19:19:23 2010
@@ -40,8 +40,8 @@ import org.apache.http.params.HttpParams
* {@link CookieSpecFactory} implementation that creates and initializes
* {@link BrowserCompatSpec} instances.
* <p>
- * The following parameters can be used to customize the behavior of this
- * class:
+ * The following parameters can be used to customize the behavior of this
+ * class:
* <ul>
* <li>{@link org.apache.http.cookie.params.CookieSpecPNames#DATE_PATTERNS}</li>
* </ul>
@@ -49,7 +49,7 @@ import org.apache.http.params.HttpParams
* @since 4.0
*/
@Immutable
-public class BrowserCompatSpecFactory implements CookieSpecFactory {
+public class BrowserCompatSpecFactory implements CookieSpecFactory {
public CookieSpec newInstance(final HttpParams params) {
if (params != null) {
Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/CookieSpecBase.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/CookieSpecBase.java?rev=937479&r1=937478&r2=937479&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/CookieSpecBase.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/CookieSpecBase.java Fri Apr 23 19:19:23 2010
@@ -23,7 +23,7 @@
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
- */
+ */
package org.apache.http.impl.cookie;
@@ -43,14 +43,14 @@ import org.apache.http.cookie.MalformedC
/**
* Cookie management functions shared by all specification.
*
- *
- * @since 4.0
+ *
+ * @since 4.0
*/
@NotThreadSafe // AbstractCookieSpec is not thread-safe
public abstract class CookieSpecBase extends AbstractCookieSpec {
-
+
protected static String getDefaultPath(final CookieOrigin origin) {
- String defaultPath = origin.getPath();
+ String defaultPath = origin.getPath();
int lastSlashIndex = defaultPath.lastIndexOf('/');
if (lastSlashIndex >= 0) {
if (lastSlashIndex == 0) {
@@ -65,7 +65,7 @@ public abstract class CookieSpecBase ext
protected static String getDefaultDomain(final CookieOrigin origin) {
return origin.getHost();
}
-
+
protected List<Cookie> parse(final HeaderElement[] elems, final CookieOrigin origin)
throws MalformedCookieException {
List<Cookie> cookies = new ArrayList<Cookie>(elems.length);
Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/DateParseException.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/DateParseException.java?rev=937479&r1=937478&r2=937479&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/DateParseException.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/DateParseException.java Fri Apr 23 19:19:23 2010
@@ -31,9 +31,9 @@ import org.apache.http.annotation.Immuta
/**
* An exception to indicate an error parsing a date string.
- *
+ *
* @see DateUtils
- *
+ *
*
* @since 4.0
*/
@@ -41,9 +41,9 @@ import org.apache.http.annotation.Immuta
public class DateParseException extends Exception {
private static final long serialVersionUID = 4417696455000643370L;
-
+
/**
- *
+ *
*/
public DateParseException() {
super();
Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/DateUtils.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/DateUtils.java?rev=937479&r1=937478&r2=937479&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/DateUtils.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/DateUtils.java Fri Apr 23 19:19:23 2010
@@ -40,10 +40,10 @@ import java.util.TimeZone;
import org.apache.http.annotation.Immutable;
/**
- * A utility class for parsing and formatting HTTP dates as used in cookies and
- * other headers. This class handles dates as defined by RFC 2616 section
+ * A utility class for parsing and formatting HTTP dates as used in cookies and
+ * other headers. This class handles dates as defined by RFC 2616 section
* 3.3.1 as well as some other common non-standard formats.
- *
+ *
*
* @since 4.0
*/
@@ -61,7 +61,7 @@ public final class DateUtils {
public static final String PATTERN_RFC1036 = "EEEE, dd-MMM-yy HH:mm:ss zzz";
/**
- * Date format pattern used to parse HTTP date headers in ANSI C
+ * Date format pattern used to parse HTTP date headers in ANSI C
* <code>asctime()</code> format.
*/
public static final String PATTERN_ASCTIME = "EEE MMM d HH:mm:ss yyyy";
@@ -73,67 +73,67 @@ public final class DateUtils {
};
private static final Date DEFAULT_TWO_DIGIT_YEAR_START;
-
+
public static final TimeZone GMT = TimeZone.getTimeZone("GMT");
-
+
static {
Calendar calendar = Calendar.getInstance();
calendar.setTimeZone(GMT);
calendar.set(2000, Calendar.JANUARY, 1, 0, 0, 0);
calendar.set(Calendar.MILLISECOND, 0);
- DEFAULT_TWO_DIGIT_YEAR_START = calendar.getTime();
+ DEFAULT_TWO_DIGIT_YEAR_START = calendar.getTime();
}
-
+
/**
* Parses a date value. The formats used for parsing the date value are retrieved from
* the default http params.
*
* @param dateValue the date value to parse
- *
+ *
* @return the parsed date
*
- * @throws DateParseException if the value could not be parsed using any of the
+ * @throws DateParseException if the value could not be parsed using any of the
* supported date formats
*/
public static Date parseDate(String dateValue) throws DateParseException {
return parseDate(dateValue, null, null);
}
-
+
/**
* Parses the date value using the given date formats.
- *
+ *
* @param dateValue the date value to parse
* @param dateFormats the date formats to use
- *
+ *
* @return the parsed date
- *
+ *
* @throws DateParseException if none of the dataFormats could parse the dateValue
*/
- public static Date parseDate(final String dateValue, String[] dateFormats)
+ public static Date parseDate(final String dateValue, String[] dateFormats)
throws DateParseException {
return parseDate(dateValue, dateFormats, null);
}
-
+
/**
* Parses the date value using the given date formats.
- *
+ *
* @param dateValue the date value to parse
* @param dateFormats the date formats to use
- * @param startDate During parsing, two digit years will be placed in the range
- * <code>startDate</code> to <code>startDate + 100 years</code>. This value may
- * be <code>null</code>. When <code>null</code> is given as a parameter, year
- * <code>2000</code> will be used.
- *
+ * @param startDate During parsing, two digit years will be placed in the range
+ * <code>startDate</code> to <code>startDate + 100 years</code>. This value may
+ * be <code>null</code>. When <code>null</code> is given as a parameter, year
+ * <code>2000</code> will be used.
+ *
* @return the parsed date
- *
+ *
* @throws DateParseException if none of the dataFormats could parse the dateValue
*/
public static Date parseDate(
- String dateValue,
+ String dateValue,
String[] dateFormats,
- Date startDate
+ Date startDate
) throws DateParseException {
-
+
if (dateValue == null) {
throw new IllegalArgumentException("dateValue is null");
}
@@ -145,8 +145,8 @@ public final class DateUtils {
}
// trim single quotes around date if present
// see issue #5279
- if (dateValue.length() > 1
- && dateValue.startsWith("'")
+ if (dateValue.length() > 1
+ && dateValue.startsWith("'")
&& dateValue.endsWith("'")
) {
dateValue = dateValue.substring (1, dateValue.length() - 1);
@@ -162,57 +162,57 @@ public final class DateUtils {
// ignore this exception, we will try the next format
}
}
-
+
// we were unable to parse the date
- throw new DateParseException("Unable to parse the date " + dateValue);
+ throw new DateParseException("Unable to parse the date " + dateValue);
}
/**
* Formats the given date according to the RFC 1123 pattern.
- *
+ *
* @param date The date to format.
* @return An RFC 1123 formatted date string.
- *
+ *
* @see #PATTERN_RFC1123
*/
public static String formatDate(Date date) {
return formatDate(date, PATTERN_RFC1123);
}
-
+
/**
* Formats the given date according to the specified pattern. The pattern
* must conform to that used by the {@link SimpleDateFormat simple date
* format} class.
- *
+ *
* @param date The date to format.
- * @param pattern The pattern to use for formatting the date.
+ * @param pattern The pattern to use for formatting the date.
* @return A formatted date string.
- *
+ *
* @throws IllegalArgumentException If the given date pattern is invalid.
- *
+ *
* @see SimpleDateFormat
*/
public static String formatDate(Date date, String pattern) {
if (date == null) throw new IllegalArgumentException("date is null");
if (pattern == null) throw new IllegalArgumentException("pattern is null");
-
+
SimpleDateFormat formatter = DateFormatHolder.formatFor(pattern);
return formatter.format(date);
}
-
- /** This class should not be instantiated. */
- private DateUtils() {
+
+ /** This class should not be instantiated. */
+ private DateUtils() {
}
-
+
/**
* A factory for {@link SimpleDateFormat}s. The instances are stored in a
* threadlocal way because SimpleDateFormat is not threadsafe as noted in
* {@link SimpleDateFormat its javadoc}.
- *
+ *
*/
final static class DateFormatHolder {
- private static final ThreadLocal<SoftReference<Map<String, SimpleDateFormat>>>
+ private static final ThreadLocal<SoftReference<Map<String, SimpleDateFormat>>>
THREADLOCAL_FORMATS = new ThreadLocal<SoftReference<Map<String, SimpleDateFormat>>>() {
@Override
@@ -220,12 +220,12 @@ public final class DateUtils {
return new SoftReference<Map<String, SimpleDateFormat>>(
new HashMap<String, SimpleDateFormat>());
}
-
+
};
/**
* creates a {@link SimpleDateFormat} for the requested format string.
- *
+ *
* @param pattern
* a non-<code>null</code> format String according to
* {@link SimpleDateFormat}. The format is not checked against
@@ -241,7 +241,7 @@ public final class DateUtils {
if (formats == null) {
formats = new HashMap<String, SimpleDateFormat>();
THREADLOCAL_FORMATS.set(
- new SoftReference<Map<String, SimpleDateFormat>>(formats));
+ new SoftReference<Map<String, SimpleDateFormat>>(formats));
}
SimpleDateFormat format = formats.get(pattern);
@@ -253,7 +253,7 @@ public final class DateUtils {
return format;
}
-
+
}
-
+
}
Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/NetscapeDomainHandler.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/NetscapeDomainHandler.java?rev=937479&r1=937478&r2=937479&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/NetscapeDomainHandler.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/NetscapeDomainHandler.java Fri Apr 23 19:19:23 2010
@@ -23,7 +23,7 @@
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
- */
+ */
package org.apache.http.impl.cookie;
import java.util.Locale;
@@ -48,7 +48,7 @@ public class NetscapeDomainHandler exten
}
@Override
- public void validate(final Cookie cookie, final CookieOrigin origin)
+ public void validate(final Cookie cookie, final CookieOrigin origin)
throws MalformedCookieException {
super.validate(cookie, origin);
// Perform Netscape Cookie draft specific validation
@@ -60,16 +60,16 @@ public class NetscapeDomainHandler exten
if (isSpecialDomain(domain)) {
if (domainParts < 2) {
throw new CookieRestrictionViolationException("Domain attribute \""
- + domain
+ + domain
+ "\" violates the Netscape cookie specification for "
+ "special domains");
}
} else {
if (domainParts < 3) {
throw new CookieRestrictionViolationException("Domain attribute \""
- + domain
+ + domain
+ "\" violates the Netscape cookie specification");
- }
+ }
}
}
}
Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/NetscapeDraftHeaderParser.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/NetscapeDraftHeaderParser.java?rev=937479&r1=937478&r2=937479&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/NetscapeDraftHeaderParser.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/NetscapeDraftHeaderParser.java Fri Apr 23 19:19:23 2010
@@ -48,16 +48,16 @@ import org.apache.http.util.CharArrayBuf
public class NetscapeDraftHeaderParser {
public final static NetscapeDraftHeaderParser DEFAULT = new NetscapeDraftHeaderParser();
-
+
private final static char[] DELIMITERS = new char[] { ';' };
-
+
private final BasicHeaderValueParser nvpParser;
-
+
public NetscapeDraftHeaderParser() {
super();
this.nvpParser = BasicHeaderValueParser.DEFAULT;
}
-
+
public HeaderElement parseHeader(
final CharArrayBuffer buffer,
final ParserCursor cursor) throws ParseException {
@@ -68,13 +68,13 @@ public class NetscapeDraftHeaderParser {
throw new IllegalArgumentException("Parser cursor may not be null");
}
NameValuePair nvp = this.nvpParser.parseNameValuePair(buffer, cursor, DELIMITERS);
- List<NameValuePair> params = new ArrayList<NameValuePair>();
+ List<NameValuePair> params = new ArrayList<NameValuePair>();
while (!cursor.atEnd()) {
NameValuePair param = this.nvpParser.parseNameValuePair(buffer, cursor, DELIMITERS);
params.add(param);
}
return new BasicHeaderElement(
- nvp.getName(),
+ nvp.getName(),
nvp.getValue(), params.toArray(new NameValuePair[params.size()]));
}
Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/NetscapeDraftSpec.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/NetscapeDraftSpec.java?rev=937479&r1=937478&r2=937479&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/NetscapeDraftSpec.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/NetscapeDraftSpec.java Fri Apr 23 19:19:23 2010
@@ -46,19 +46,19 @@ import org.apache.http.message.ParserCur
import org.apache.http.util.CharArrayBuffer;
/**
- * This {@link CookieSpec} implementation conforms to the original draft
- * specification published by Netscape Communications. It should be avoided
+ * This {@link CookieSpec} implementation conforms to the original draft
+ * specification published by Netscape Communications. It should be avoided
* unless absolutely necessary for compatibility with legacy code.
- *
- * @since 4.0
+ *
+ * @since 4.0
*/
@NotThreadSafe // superclass is @NotThreadSafe
public class NetscapeDraftSpec extends CookieSpecBase {
protected static final String EXPIRES_PATTERN = "EEE, dd-MMM-yy HH:mm:ss z";
-
- private final String[] datepatterns;
-
+
+ private final String[] datepatterns;
+
/** Default constructor */
public NetscapeDraftSpec(final String[] datepatterns) {
super();
@@ -80,26 +80,26 @@ public class NetscapeDraftSpec extends C
public NetscapeDraftSpec() {
this(null);
}
-
+
/**
* Parses the Set-Cookie value into an array of <tt>Cookie</tt>s.
*
* <p>Syntax of the Set-Cookie HTTP Response Header:</p>
- *
- * <p>This is the format a CGI script would use to add to
- * the HTTP headers a new piece of data which is to be stored by
+ *
+ * <p>This is the format a CGI script would use to add to
+ * the HTTP headers a new piece of data which is to be stored by
* the client for later retrieval.</p>
- *
+ *
* <PRE>
* Set-Cookie: NAME=VALUE; expires=DATE; path=PATH; domain=DOMAIN_NAME; secure
* </PRE>
*
- * <p>Please note that Netscape draft specification does not fully
- * conform to the HTTP header format. Netscape draft does not specify
- * whether multiple cookies may be sent in one header. Hence, comma
- * character may be present in unquoted cookie value or unquoted
+ * <p>Please note that Netscape draft specification does not fully
+ * conform to the HTTP header format. Netscape draft does not specify
+ * whether multiple cookies may be sent in one header. Hence, comma
+ * character may be present in unquoted cookie value or unquoted
* parameter value.</p>
- *
+ *
* @see <a href="http://wp.netscape.com/newsref/std/cookie_spec.html">
* The Cookie Spec.</a>
*
@@ -107,7 +107,7 @@ public class NetscapeDraftSpec extends C
* @return an array of <tt>Cookie</tt>s parsed from the Set-Cookie value
* @throws MalformedCookieException if an exception occurs during parsing
*/
- public List<Cookie> parse(final Header header, final CookieOrigin origin)
+ public List<Cookie> parse(final Header header, final CookieOrigin origin)
throws MalformedCookieException {
if (header == null) {
throw new IllegalArgumentException("Header may not be null");
@@ -125,7 +125,7 @@ public class NetscapeDraftSpec extends C
if (header instanceof FormattedHeader) {
buffer = ((FormattedHeader) header).getBuffer();
cursor = new ParserCursor(
- ((FormattedHeader) header).getValuePos(),
+ ((FormattedHeader) header).getValuePos(),
buffer.length());
} else {
String s = header.getValue();
@@ -173,10 +173,10 @@ public class NetscapeDraftSpec extends C
public Header getVersionHeader() {
return null;
}
-
+
@Override
public String toString() {
return "netscape";
}
-
+
}
Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/NetscapeDraftSpecFactory.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/NetscapeDraftSpecFactory.java?rev=937479&r1=937478&r2=937479&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/NetscapeDraftSpecFactory.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/NetscapeDraftSpecFactory.java Fri Apr 23 19:19:23 2010
@@ -40,8 +40,8 @@ import org.apache.http.params.HttpParams
* {@link CookieSpecFactory} implementation that creates and initializes
* {@link NetscapeDraftSpec} instances.
* <p>
- * The following parameters can be used to customize the behavior of this
- * class:
+ * The following parameters can be used to customize the behavior of this
+ * class:
* <ul>
* <li>{@link org.apache.http.cookie.params.CookieSpecPNames#DATE_PATTERNS}</li>
* </ul>
Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/PublicSuffixFilter.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/PublicSuffixFilter.java?rev=937479&r1=937478&r2=937479&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/PublicSuffixFilter.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/PublicSuffixFilter.java Fri Apr 23 19:19:23 2010
@@ -47,8 +47,8 @@ import org.apache.http.cookie.SetCookie;
* to never match a suffix from a black list. May be used to provide
* additional security for cross-site attack types by preventing
* cookies from apparent domains that are not publicly available.
- * An uptodate list of suffixes can be obtained from
- * <a href="http://publicsuffix.org/">publicsuffix.org</a>
+ * An uptodate list of suffixes can be obtained from
+ * <a href="http://publicsuffix.org/">publicsuffix.org</a>
*
* @since 4.0
*/
@@ -60,7 +60,7 @@ public class PublicSuffixFilter implemen
public PublicSuffixFilter(CookieAttributeHandler wrapped) {
this.wrapped = wrapped;
}
-
+
/**
* Sets the suffix blacklist patterns.
* A pattern can be "com", "*.jp"
@@ -70,7 +70,7 @@ public class PublicSuffixFilter implemen
public void setPublicSuffixes(Collection<String> suffixes) {
this.suffixes = new HashSet<String>(suffixes);
}
-
+
/**
* Sets the exceptions from the blacklist. Exceptions can not be patterns.
* TODO add support for patterns
@@ -95,20 +95,20 @@ public class PublicSuffixFilter implemen
public void validate(Cookie cookie, CookieOrigin origin) throws MalformedCookieException {
wrapped.validate(cookie, origin);
}
-
+
private boolean isForPublicSuffix(Cookie cookie) {
String domain = cookie.getDomain();
if (domain.startsWith(".")) domain = domain.substring(1);
domain = Punycode.toUnicode(domain);
-
+
// An exception rule takes priority over any other matching rule.
if (this.exceptions != null) {
if (this.exceptions.contains(domain)) return false;
}
-
+
if (this.suffixes == null) return false;
-
+
do {
if (this.suffixes.contains(domain)) return true;
// patterns
@@ -117,7 +117,7 @@ public class PublicSuffixFilter implemen
if (nextdot == -1) break;
domain = "*" + domain.substring(nextdot);
} while (domain.length() > 0);
-
+
return false;
}
}
Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/PublicSuffixListParser.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/PublicSuffixListParser.java?rev=937479&r1=937478&r2=937479&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/PublicSuffixListParser.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/PublicSuffixListParser.java Fri Apr 23 19:19:23 2010
@@ -49,7 +49,7 @@ import org.apache.http.annotation.Immuta
public class PublicSuffixListParser {
private static final int MAX_LINE_LEN = 256;
private final PublicSuffixFilter filter;
-
+
PublicSuffixListParser(PublicSuffixFilter filter) {
this.filter = filter;
}
@@ -58,7 +58,7 @@ public class PublicSuffixListParser {
* Parses the public suffix list format.
* When creating the reader from the file, make sure to
* use the correct encoding (the original list is in UTF-8).
- *
+ *
* @param list the suffix list. The caller is responsible for closing the reader.
* @throws IOException on error while reading from list
*/
@@ -75,22 +75,22 @@ public class PublicSuffixListParser {
if (line.startsWith("//")) continue; //entire lines can also be commented using //
if (line.startsWith(".")) line = line.substring(1); // A leading dot is optional
// An exclamation mark (!) at the start of a rule marks an exception to a previous wildcard rule
- boolean isException = line.startsWith("!");
+ boolean isException = line.startsWith("!");
if (isException) line = line.substring(1);
-
+
if (isException) {
exceptions.add(line);
} else {
rules.add(line);
}
}
-
+
filter.setPublicSuffixes(rules);
filter.setExceptions(exceptions);
}
-
+
/**
- *
+ *
* @param r
* @param sb
* @return false when the end of the stream is reached
Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2109DomainHandler.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2109DomainHandler.java?rev=937479&r1=937478&r2=937479&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2109DomainHandler.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2109DomainHandler.java Fri Apr 23 19:19:23 2010
@@ -23,7 +23,7 @@
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
- */
+ */
package org.apache.http.impl.cookie;
import java.util.Locale;
@@ -47,8 +47,8 @@ public class RFC2109DomainHandler implem
public RFC2109DomainHandler() {
super();
}
-
- public void parse(final SetCookie cookie, final String value)
+
+ public void parse(final SetCookie cookie, final String value)
throws MalformedCookieException {
if (cookie == null) {
throw new IllegalArgumentException("Cookie may not be null");
@@ -62,7 +62,7 @@ public class RFC2109DomainHandler implem
cookie.setDomain(value);
}
- public void validate(final Cookie cookie, final CookieOrigin origin)
+ public void validate(final Cookie cookie, final CookieOrigin origin)
throws MalformedCookieException {
if (cookie == null) {
throw new IllegalArgumentException("Cookie may not be null");
@@ -78,40 +78,40 @@ public class RFC2109DomainHandler implem
if (!domain.equals(host)) {
int dotIndex = domain.indexOf('.');
if (dotIndex == -1) {
- throw new CookieRestrictionViolationException("Domain attribute \""
- + domain
- + "\" does not match the host \""
+ throw new CookieRestrictionViolationException("Domain attribute \""
+ + domain
+ + "\" does not match the host \""
+ host + "\"");
}
// domain must start with dot
if (!domain.startsWith(".")) {
- throw new CookieRestrictionViolationException("Domain attribute \""
- + domain
+ throw new CookieRestrictionViolationException("Domain attribute \""
+ + domain
+ "\" violates RFC 2109: domain must start with a dot");
}
// domain must have at least one embedded dot
dotIndex = domain.indexOf('.', 1);
if (dotIndex < 0 || dotIndex == domain.length() - 1) {
- throw new CookieRestrictionViolationException("Domain attribute \""
- + domain
+ throw new CookieRestrictionViolationException("Domain attribute \""
+ + domain
+ "\" violates RFC 2109: domain must contain an embedded dot");
}
host = host.toLowerCase(Locale.ENGLISH);
if (!host.endsWith(domain)) {
throw new CookieRestrictionViolationException(
- "Illegal domain attribute \"" + domain
+ "Illegal domain attribute \"" + domain
+ "\". Domain of origin: \"" + host + "\"");
}
// host minus domain may not contain any dots
String hostWithoutDomain = host.substring(0, host.length() - domain.length());
if (hostWithoutDomain.indexOf('.') != -1) {
- throw new CookieRestrictionViolationException("Domain attribute \""
- + domain
+ throw new CookieRestrictionViolationException("Domain attribute \""
+ + domain
+ "\" violates RFC 2109: host minus domain may not contain any dots");
}
}
}
-
+
public boolean match(final Cookie cookie, final CookieOrigin origin) {
if (cookie == null) {
throw new IllegalArgumentException("Cookie may not be null");
@@ -126,5 +126,5 @@ public class RFC2109DomainHandler implem
}
return host.equals(domain) || (domain.startsWith(".") && host.endsWith(domain));
}
-
+
}
Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2109Spec.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2109Spec.java?rev=937479&r1=937478&r2=937479&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2109Spec.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2109Spec.java Fri Apr 23 19:19:23 2010
@@ -50,25 +50,25 @@ import org.apache.http.util.CharArrayBuf
* RFC 2109 compliant {@link CookieSpec} implementation. This is an older
* version of the official HTTP state management specification superseded
* by RFC 2965.
- *
+ *
* @see RFC2965Spec
- *
- * @since 4.0
+ *
+ * @since 4.0
*/
@NotThreadSafe // superclass is @NotThreadSafe
public class RFC2109Spec extends CookieSpecBase {
- private final static CookiePathComparator PATH_COMPARATOR = new CookiePathComparator();
-
+ private final static CookiePathComparator PATH_COMPARATOR = new CookiePathComparator();
+
private final static String[] DATE_PATTERNS = {
DateUtils.PATTERN_RFC1123,
DateUtils.PATTERN_RFC1036,
- DateUtils.PATTERN_ASCTIME
- };
-
- private final String[] datepatterns;
+ DateUtils.PATTERN_ASCTIME
+ };
+
+ private final String[] datepatterns;
private final boolean oneHeader;
-
+
/** Default constructor */
public RFC2109Spec(final String[] datepatterns, boolean oneHeader) {
super();
@@ -92,8 +92,8 @@ public class RFC2109Spec extends CookieS
public RFC2109Spec() {
this(null, false);
}
-
- public List<Cookie> parse(final Header header, final CookieOrigin origin)
+
+ public List<Cookie> parse(final Header header, final CookieOrigin origin)
throws MalformedCookieException {
if (header == null) {
throw new IllegalArgumentException("Header may not be null");
@@ -110,7 +110,7 @@ public class RFC2109Spec extends CookieS
}
@Override
- public void validate(final Cookie cookie, final CookieOrigin origin)
+ public void validate(final Cookie cookie, final CookieOrigin origin)
throws MalformedCookieException {
if (cookie == null) {
throw new IllegalArgumentException("Cookie may not be null");
@@ -181,7 +181,7 @@ public class RFC2109Spec extends CookieS
}
return headers;
}
-
+
/**
* Return a name/value string suitable for sending in a <tt>"Cookie"</tt>
* header as defined in RFC 2109 for backward compatibility with cookie
@@ -189,9 +189,9 @@ public class RFC2109Spec extends CookieS
* @param buffer The char array buffer to use for output
* @param name The cookie name
* @param value The cookie value
- * @param version The cookie version
+ * @param version The cookie version
*/
- protected void formatParamAsVer(final CharArrayBuffer buffer,
+ protected void formatParamAsVer(final CharArrayBuffer buffer,
final String name, final String value, int version) {
buffer.append(name);
buffer.append("=");
@@ -207,24 +207,24 @@ public class RFC2109Spec extends CookieS
}
/**
- * Return a string suitable for sending in a <tt>"Cookie"</tt> header
+ * Return a string suitable for sending in a <tt>"Cookie"</tt> header
* as defined in RFC 2109 for backward compatibility with cookie version 0
* @param buffer The char array buffer to use for output
* @param cookie The {@link Cookie} to be formatted as string
* @param version The version to use.
*/
- protected void formatCookieAsVer(final CharArrayBuffer buffer,
+ protected void formatCookieAsVer(final CharArrayBuffer buffer,
final Cookie cookie, int version) {
formatParamAsVer(buffer, cookie.getName(), cookie.getValue(), version);
if (cookie.getPath() != null) {
- if (cookie instanceof ClientCookie
+ if (cookie instanceof ClientCookie
&& ((ClientCookie) cookie).containsAttribute(ClientCookie.PATH_ATTR)) {
buffer.append("; ");
formatParamAsVer(buffer, "$Path", cookie.getPath(), version);
}
}
if (cookie.getDomain() != null) {
- if (cookie instanceof ClientCookie
+ if (cookie instanceof ClientCookie
&& ((ClientCookie) cookie).containsAttribute(ClientCookie.DOMAIN_ATTR)) {
buffer.append("; ");
formatParamAsVer(buffer, "$Domain", cookie.getDomain(), version);
@@ -239,10 +239,10 @@ public class RFC2109Spec extends CookieS
public Header getVersionHeader() {
return null;
}
-
+
@Override
public String toString() {
return "rfc2109";
}
-
+
}
Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2109SpecFactory.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2109SpecFactory.java?rev=937479&r1=937478&r2=937479&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2109SpecFactory.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2109SpecFactory.java Fri Apr 23 19:19:23 2010
@@ -40,8 +40,8 @@ import org.apache.http.params.HttpParams
* {@link CookieSpecFactory} implementation that creates and initializes
* {@link RFC2109Spec} instances.
* <p>
- * The following parameters can be used to customize the behavior of this
- * class:
+ * The following parameters can be used to customize the behavior of this
+ * class:
* <ul>
* <li>{@link org.apache.http.cookie.params.CookieSpecPNames#DATE_PATTERNS}</li>
* <li>{@link org.apache.http.cookie.params.CookieSpecPNames#SINGLE_COOKIE_HEADER}</li>
Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2109VersionHandler.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2109VersionHandler.java?rev=937479&r1=937478&r2=937479&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2109VersionHandler.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2109VersionHandler.java Fri Apr 23 19:19:23 2010
@@ -23,7 +23,7 @@
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
- */
+ */
package org.apache.http.impl.cookie;
import org.apache.http.annotation.Immutable;
@@ -44,8 +44,8 @@ public class RFC2109VersionHandler exten
public RFC2109VersionHandler() {
super();
}
-
- public void parse(final SetCookie cookie, final String value)
+
+ public void parse(final SetCookie cookie, final String value)
throws MalformedCookieException {
if (cookie == null) {
throw new IllegalArgumentException("Cookie may not be null");
@@ -59,13 +59,13 @@ public class RFC2109VersionHandler exten
try {
cookie.setVersion(Integer.parseInt(value));
} catch (NumberFormatException e) {
- throw new MalformedCookieException("Invalid version: "
+ throw new MalformedCookieException("Invalid version: "
+ e.getMessage());
}
}
@Override
- public void validate(final Cookie cookie, final CookieOrigin origin)
+ public void validate(final Cookie cookie, final CookieOrigin origin)
throws MalformedCookieException {
if (cookie == null) {
throw new IllegalArgumentException("Cookie may not be null");
@@ -74,5 +74,5 @@ public class RFC2109VersionHandler exten
throw new CookieRestrictionViolationException("Cookie version may not be negative");
}
}
-
+
}
Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2965CommentUrlAttributeHandler.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2965CommentUrlAttributeHandler.java?rev=937479&r1=937478&r2=937479&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2965CommentUrlAttributeHandler.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2965CommentUrlAttributeHandler.java Fri Apr 23 19:19:23 2010
@@ -47,7 +47,7 @@ public class RFC2965CommentUrlAttributeH
public RFC2965CommentUrlAttributeHandler() {
super();
}
-
+
public void parse(final SetCookie cookie, final String commenturl)
throws MalformedCookieException {
if (cookie instanceof SetCookie2) {
@@ -63,5 +63,5 @@ public class RFC2965CommentUrlAttributeH
public boolean match(final Cookie cookie, final CookieOrigin origin) {
return true;
}
-
+
}
\ No newline at end of file
Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2965DiscardAttributeHandler.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2965DiscardAttributeHandler.java?rev=937479&r1=937478&r2=937479&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2965DiscardAttributeHandler.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2965DiscardAttributeHandler.java Fri Apr 23 19:19:23 2010
@@ -47,7 +47,7 @@ public class RFC2965DiscardAttributeHand
public RFC2965DiscardAttributeHandler() {
super();
}
-
+
public void parse(final SetCookie cookie, final String commenturl)
throws MalformedCookieException {
if (cookie instanceof SetCookie2) {
@@ -63,5 +63,5 @@ public class RFC2965DiscardAttributeHand
public boolean match(final Cookie cookie, final CookieOrigin origin) {
return true;
}
-
+
}
\ No newline at end of file
Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2965DomainAttributeHandler.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2965DomainAttributeHandler.java?rev=937479&r1=937478&r2=937479&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2965DomainAttributeHandler.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2965DomainAttributeHandler.java Fri Apr 23 19:19:23 2010
@@ -41,7 +41,7 @@ import org.apache.http.cookie.SetCookie;
/**
* <tt>"Domain"</tt> cookie attribute handler for RFC 2965 cookie spec.
- *
+ *
*
* @since 3.1
*/
@@ -73,7 +73,7 @@ public class RFC2965DomainAttributeHandl
// Per RFC 2965 section 3.2.2
// "... If an explicitly specified value does not start with
// a dot, the user agent supplies a leading dot ..."
- // That effectively implies that the domain attribute
+ // That effectively implies that the domain attribute
// MAY NOT be an IP address of a host name
domain = '.' + domain;
}
@@ -120,7 +120,7 @@ public class RFC2965DomainAttributeHandl
}
String cookieDomain = cookie.getDomain().toLowerCase(Locale.ENGLISH);
- if (cookie instanceof ClientCookie
+ if (cookie instanceof ClientCookie
&& ((ClientCookie) cookie).containsAttribute(ClientCookie.DOMAIN_ATTR)) {
// Domain attribute must start with a dot
if (!cookieDomain.startsWith(".")) {
Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2965PortAttributeHandler.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2965PortAttributeHandler.java?rev=937479&r1=937478&r2=937479&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2965PortAttributeHandler.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2965PortAttributeHandler.java Fri Apr 23 19:19:23 2010
@@ -131,7 +131,7 @@ public class RFC2965PortAttributeHandler
throw new IllegalArgumentException("Cookie origin may not be null");
}
int port = origin.getPort();
- if (cookie instanceof ClientCookie
+ if (cookie instanceof ClientCookie
&& ((ClientCookie) cookie).containsAttribute(ClientCookie.PORT_ATTR)) {
if (!portMatch(port, cookie.getPorts())) {
throw new CookieRestrictionViolationException(
@@ -154,7 +154,7 @@ public class RFC2965PortAttributeHandler
throw new IllegalArgumentException("Cookie origin may not be null");
}
int port = origin.getPort();
- if (cookie instanceof ClientCookie
+ if (cookie instanceof ClientCookie
&& ((ClientCookie) cookie).containsAttribute(ClientCookie.PORT_ATTR)) {
if (cookie.getPorts() == null) {
// Invalid cookie state: port not specified
Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2965Spec.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2965Spec.java?rev=937479&r1=937478&r2=937479&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2965Spec.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2965Spec.java Fri Apr 23 19:19:23 2010
@@ -55,14 +55,14 @@ import org.apache.http.util.CharArrayBuf
@NotThreadSafe // superclass is @NotThreadSafe
public class RFC2965Spec extends RFC2109Spec {
- /**
- * Default constructor
- *
+ /**
+ * Default constructor
+ *
*/
public RFC2965Spec() {
this(null, false);
}
-
+
public RFC2965Spec(final String[] datepatterns, boolean oneHeader) {
super(datepatterns, oneHeader);
registerAttribHandler(ClientCookie.DOMAIN_ATTR, new RFC2965DomainAttributeHandler());
@@ -74,7 +74,7 @@ public class RFC2965Spec extends RFC2109
@Override
public List<Cookie> parse(
- final Header header,
+ final Header header,
CookieOrigin origin) throws MalformedCookieException {
if (header == null) {
throw new IllegalArgumentException("Header may not be null");
@@ -90,17 +90,17 @@ public class RFC2965Spec extends RFC2109
HeaderElement[] elems = header.getElements();
return createCookies(elems, origin);
}
-
+
@Override
protected List<Cookie> parse(
- final HeaderElement[] elems,
+ final HeaderElement[] elems,
CookieOrigin origin) throws MalformedCookieException {
origin = adjustEffectiveHost(origin);
return createCookies(elems, origin);
}
private List<Cookie> createCookies(
- final HeaderElement[] elems,
+ final HeaderElement[] elems,
final CookieOrigin origin) throws MalformedCookieException {
List<Cookie> cookies = new ArrayList<Cookie>(elems.length);
for (HeaderElement headerelement : elems) {
@@ -170,7 +170,7 @@ public class RFC2965Spec extends RFC2109
* Adds valid Port attribute value, e.g. "8000,8001,8002"
*/
@Override
- protected void formatCookieAsVer(final CharArrayBuffer buffer,
+ protected void formatCookieAsVer(final CharArrayBuffer buffer,
final Cookie cookie, int version) {
super.formatCookieAsVer(buffer, cookie, version);
// format port attribute
@@ -195,7 +195,7 @@ public class RFC2965Spec extends RFC2109
}
}
}
-
+
/**
* Set 'effective host name' as defined in RFC 2965.
* <p>
@@ -209,8 +209,8 @@ public class RFC2965Spec extends RFC2109
*/
private static CookieOrigin adjustEffectiveHost(final CookieOrigin origin) {
String host = origin.getHost();
-
- // Test if the host name appears to be a fully qualified DNS name,
+
+ // Test if the host name appears to be a fully qualified DNS name,
// IPv4 address or IPv6 address
boolean isLocalHost = true;
for (int i = 0; i < host.length(); i++) {
@@ -223,9 +223,9 @@ public class RFC2965Spec extends RFC2109
if (isLocalHost) {
host += ".local";
return new CookieOrigin(
- host,
- origin.getPort(),
- origin.getPath(),
+ host,
+ origin.getPort(),
+ origin.getPath(),
origin.isSecure());
} else {
return origin;
@@ -246,11 +246,11 @@ public class RFC2965Spec extends RFC2109
buffer.append(Integer.toString(getVersion()));
return new BufferedHeader(buffer);
}
-
+
@Override
public String toString() {
return "rfc2965";
}
-
+
}
Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2965SpecFactory.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2965SpecFactory.java?rev=937479&r1=937478&r2=937479&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2965SpecFactory.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2965SpecFactory.java Fri Apr 23 19:19:23 2010
@@ -40,8 +40,8 @@ import org.apache.http.params.HttpParams
* {@link CookieSpecFactory} implementation that creates and initializes
* {@link RFC2965Spec} instances.
* <p>
- * The following parameters can be used to customize the behavior of this
- * class:
+ * The following parameters can be used to customize the behavior of this
+ * class:
* <ul>
* <li>{@link org.apache.http.cookie.params.CookieSpecPNames#DATE_PATTERNS}</li>
* <li>{@link org.apache.http.cookie.params.CookieSpecPNames#SINGLE_COOKIE_HEADER}</li>
Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2965VersionAttributeHandler.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2965VersionAttributeHandler.java?rev=937479&r1=937478&r2=937479&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2965VersionAttributeHandler.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2965VersionAttributeHandler.java Fri Apr 23 19:19:23 2010
@@ -49,7 +49,7 @@ public class RFC2965VersionAttributeHand
public RFC2965VersionAttributeHandler() {
super();
}
-
+
/**
* Parse cookie version attribute.
*/
@@ -83,7 +83,7 @@ public class RFC2965VersionAttributeHand
throw new IllegalArgumentException("Cookie may not be null");
}
if (cookie instanceof SetCookie2) {
- if (cookie instanceof ClientCookie
+ if (cookie instanceof ClientCookie
&& !((ClientCookie) cookie).containsAttribute(ClientCookie.VERSION_ATTR)) {
throw new CookieRestrictionViolationException(
"Violates RFC 2965. Version attribute is required.");
Modified: httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/auth/TestCredentials.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/auth/TestCredentials.java?rev=937479&r1=937478&r2=937479&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/auth/TestCredentials.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/auth/TestCredentials.java Fri Apr 23 19:19:23 2010
@@ -57,116 +57,116 @@ public class TestCredentials extends Tes
public void testUsernamePasswordCredentialsBasics() {
UsernamePasswordCredentials creds1 = new UsernamePasswordCredentials(
- "name", "pwd");
+ "name", "pwd");
assertEquals("name", creds1.getUserName());
- assertEquals(new BasicUserPrincipal("name"),
+ assertEquals(new BasicUserPrincipal("name"),
creds1.getUserPrincipal());
assertEquals("pwd", creds1.getPassword());
assertEquals("[principal: name]", creds1.toString());
UsernamePasswordCredentials creds2 = new UsernamePasswordCredentials(
- "name:pwd");
+ "name:pwd");
assertEquals("name", creds2.getUserName());
- assertEquals(new BasicUserPrincipal("name"),
+ assertEquals(new BasicUserPrincipal("name"),
creds2.getUserPrincipal());
assertEquals("pwd", creds2.getPassword());
assertEquals("[principal: name]", creds2.toString());
UsernamePasswordCredentials creds3 = new UsernamePasswordCredentials(
- "name");
+ "name");
assertEquals("name", creds3.getUserName());
- assertEquals(new BasicUserPrincipal("name"),
+ assertEquals(new BasicUserPrincipal("name"),
creds3.getUserPrincipal());
assertEquals(null, creds3.getPassword());
assertEquals("[principal: name]", creds3.toString());
}
-
+
public void testNTCredentialsBasics() {
NTCredentials creds1 = new NTCredentials(
- "name", "pwd", "localhost", "domain");
+ "name", "pwd", "localhost", "domain");
assertEquals("name", creds1.getUserName());
- assertEquals(new NTUserPrincipal("DOMAIN", "name"),
+ assertEquals(new NTUserPrincipal("DOMAIN", "name"),
creds1.getUserPrincipal());
assertEquals("pwd", creds1.getPassword());
- assertEquals("[principal: DOMAIN/name][workstation: LOCALHOST]",
+ assertEquals("[principal: DOMAIN/name][workstation: LOCALHOST]",
creds1.toString());
NTCredentials creds2 = new NTCredentials(
- "name", null, null, null);
+ "name", null, null, null);
assertEquals("name", creds2.getUserName());
- assertEquals(new NTUserPrincipal(null, "name"),
+ assertEquals(new NTUserPrincipal(null, "name"),
creds2.getUserPrincipal());
assertEquals(null, creds2.getPassword());
- assertEquals("[principal: name][workstation: null]",
+ assertEquals("[principal: name][workstation: null]",
creds2.toString());
NTCredentials creds3 = new NTCredentials(
- "domain/name:pwd");
+ "domain/name:pwd");
assertEquals("name", creds3.getUserName());
- assertEquals(new NTUserPrincipal("DOMAIN", "name"),
+ assertEquals(new NTUserPrincipal("DOMAIN", "name"),
creds3.getUserPrincipal());
assertEquals("pwd", creds3.getPassword());
- assertEquals("[principal: DOMAIN/name][workstation: null]",
+ assertEquals("[principal: DOMAIN/name][workstation: null]",
creds3.toString());
NTCredentials creds4 = new NTCredentials(
- "domain/name");
+ "domain/name");
assertEquals("name", creds4.getUserName());
- assertEquals(new NTUserPrincipal("DOMAIN", "name"),
+ assertEquals(new NTUserPrincipal("DOMAIN", "name"),
creds4.getUserPrincipal());
assertEquals(null, creds4.getPassword());
- assertEquals("[principal: DOMAIN/name][workstation: null]",
+ assertEquals("[principal: DOMAIN/name][workstation: null]",
creds4.toString());
NTCredentials creds5 = new NTCredentials(
- "name");
+ "name");
assertEquals("name", creds5.getUserName());
- assertEquals(new NTUserPrincipal(null, "name"),
+ assertEquals(new NTUserPrincipal(null, "name"),
creds5.getUserPrincipal());
assertEquals(null, creds5.getPassword());
- assertEquals("[principal: name][workstation: null]",
+ assertEquals("[principal: name][workstation: null]",
creds5.toString());
}
-
+
public void testUsernamePasswordCredentialsHashCode() {
UsernamePasswordCredentials creds1 = new UsernamePasswordCredentials(
- "name", "pwd");
+ "name", "pwd");
UsernamePasswordCredentials creds2 = new UsernamePasswordCredentials(
- "othername", "pwd");
+ "othername", "pwd");
UsernamePasswordCredentials creds3 = new UsernamePasswordCredentials(
- "name", "otherpwd");
+ "name", "otherpwd");
assertTrue(creds1.hashCode() == creds1.hashCode());
assertTrue(creds1.hashCode() != creds2.hashCode());
assertTrue(creds1.hashCode() == creds3.hashCode());
}
-
+
public void testUsernamePasswordCredentialsEquals() {
UsernamePasswordCredentials creds1 = new UsernamePasswordCredentials(
- "name", "pwd");
+ "name", "pwd");
UsernamePasswordCredentials creds2 = new UsernamePasswordCredentials(
- "othername", "pwd");
+ "othername", "pwd");
UsernamePasswordCredentials creds3 = new UsernamePasswordCredentials(
- "name", "otherpwd");
+ "name", "otherpwd");
assertTrue(creds1.equals(creds1));
assertFalse(creds1.equals(creds2));
assertTrue(creds1.equals(creds3));
}
-
+
public void testNTCredentialsHashCode() {
NTCredentials creds1 = new NTCredentials(
- "name", "pwd", "somehost", "domain");
+ "name", "pwd", "somehost", "domain");
NTCredentials creds2 = new NTCredentials(
- "othername", "pwd", "somehost", "domain");
+ "othername", "pwd", "somehost", "domain");
NTCredentials creds3 = new NTCredentials(
- "name", "otherpwd", "SomeHost", "Domain");
+ "name", "otherpwd", "SomeHost", "Domain");
NTCredentials creds4 = new NTCredentials(
- "name", "pwd", "otherhost", "domain");
+ "name", "pwd", "otherhost", "domain");
NTCredentials creds5 = new NTCredentials(
- "name", "pwd", null, "domain");
+ "name", "pwd", null, "domain");
NTCredentials creds6 = new NTCredentials(
- "name", "pwd", "somehost", "ms");
+ "name", "pwd", "somehost", "ms");
NTCredentials creds7 = new NTCredentials(
- "name", "pwd", "somehost", null);
+ "name", "pwd", "somehost", null);
NTCredentials creds8 = new NTCredentials(
- "name", "pwd", null, "domain");
+ "name", "pwd", null, "domain");
NTCredentials creds9 = new NTCredentials(
- "name", "pwd", "somehost", null);
+ "name", "pwd", "somehost", null);
assertTrue(creds1.hashCode() == creds1.hashCode());
assertTrue(creds1.hashCode() != creds2.hashCode());
@@ -178,26 +178,26 @@ public class TestCredentials extends Tes
assertTrue(creds8.hashCode() == creds5.hashCode());
assertTrue(creds9.hashCode() == creds7.hashCode());
}
-
+
public void testNTCredentialsEquals() {
NTCredentials creds1 = new NTCredentials(
- "name", "pwd", "somehost", "domain");
+ "name", "pwd", "somehost", "domain");
NTCredentials creds2 = new NTCredentials(
- "othername", "pwd", "somehost", "domain");
+ "othername", "pwd", "somehost", "domain");
NTCredentials creds3 = new NTCredentials(
- "name", "otherpwd", "SomeHost", "Domain");
+ "name", "otherpwd", "SomeHost", "Domain");
NTCredentials creds4 = new NTCredentials(
- "name", "pwd", "otherhost", "domain");
+ "name", "pwd", "otherhost", "domain");
NTCredentials creds5 = new NTCredentials(
- "name", "pwd", null, "domain");
+ "name", "pwd", null, "domain");
NTCredentials creds6 = new NTCredentials(
- "name", "pwd", "somehost", "ms");
+ "name", "pwd", "somehost", "ms");
NTCredentials creds7 = new NTCredentials(
- "name", "pwd", "somehost", null);
+ "name", "pwd", "somehost", null);
NTCredentials creds8 = new NTCredentials(
- "name", "pwd", null, "domain");
+ "name", "pwd", null, "domain");
NTCredentials creds9 = new NTCredentials(
- "name", "pwd", "somehost", null);
+ "name", "pwd", "somehost", null);
assertTrue(creds1.equals(creds1));
assertFalse(creds1.equals(creds2));
@@ -208,11 +208,11 @@ public class TestCredentials extends Tes
assertFalse(creds1.equals(creds7));
assertTrue(creds8.equals(creds5));
assertTrue(creds9.equals(creds7));
-
+
}
public void testUsernamePasswordCredentialsSerialization() throws Exception {
- UsernamePasswordCredentials orig = new UsernamePasswordCredentials("name", "pwd");
+ UsernamePasswordCredentials orig = new UsernamePasswordCredentials("name", "pwd");
ByteArrayOutputStream outbuffer = new ByteArrayOutputStream();
ObjectOutputStream outstream = new ObjectOutputStream(outbuffer);
outstream.writeObject(orig);
@@ -223,9 +223,9 @@ public class TestCredentials extends Tes
UsernamePasswordCredentials clone = (UsernamePasswordCredentials) instream.readObject();
assertEquals(orig, clone);
}
-
+
public void testNTCredentialsSerialization() throws Exception {
- NTCredentials orig = new NTCredentials("name", "pwd", "somehost", "domain");
+ NTCredentials orig = new NTCredentials("name", "pwd", "somehost", "domain");
ByteArrayOutputStream outbuffer = new ByteArrayOutputStream();
ObjectOutputStream outstream = new ObjectOutputStream(outbuffer);
outstream.writeObject(orig);
@@ -236,5 +236,5 @@ public class TestCredentials extends Tes
NTCredentials clone = (NTCredentials) instream.readObject();
assertEquals(orig, clone);
}
-
+
}
Modified: httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/client/methods/TestHttpOptions.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/client/methods/TestHttpOptions.java?rev=937479&r1=937478&r2=937479&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/client/methods/TestHttpOptions.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/client/methods/TestHttpOptions.java Fri Apr 23 19:19:23 2010
@@ -58,16 +58,16 @@ public class TestHttpOptions extends Tes
public void testMultipleAllows() {
ProtocolVersion proto = new ProtocolVersion("HTTP", 1, 1);
- BasicStatusLine line = new BasicStatusLine(proto, 200, "test reason");
+ BasicStatusLine line = new BasicStatusLine(proto, 200, "test reason");
BasicHttpResponse resp = new BasicHttpResponse(line);
resp.addHeader("Allow", "POST");
resp.addHeader("Allow", "GET");
HttpOptions opt = new HttpOptions();
Set<String> methodsName = opt.getAllowedMethods(resp);
-
+
assertTrue(methodsName.contains("POST"));
assertTrue(methodsName.contains("GET"));
}
-
+
}
Modified: httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/client/methods/TestHttpRequestBase.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/client/methods/TestHttpRequestBase.java?rev=937479&r1=937478&r2=937479&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/client/methods/TestHttpRequestBase.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/client/methods/TestHttpRequestBase.java Fri Apr 23 19:19:23 2010
@@ -67,12 +67,12 @@ public class TestHttpRequestBase extends
assertEquals("http://host/path", httpget.getRequestLine().getUri());
assertEquals(HttpVersion.HTTP_1_0, httpget.getRequestLine().getProtocolVersion());
}
-
+
public void testEmptyURI() throws Exception {
HttpGet httpget = new HttpGet("");
assertEquals("/", httpget.getRequestLine().getUri());
}
-
+
public void testCloneBasicRequests() throws Exception {
HttpGet httpget = new HttpGet("http://host/path");
httpget.addHeader("h1", "this header");
@@ -81,21 +81,21 @@ public class TestHttpRequestBase extends
httpget.getParams().setParameter("p1", Integer.valueOf(1));
httpget.getParams().setParameter("p2", "whatever");
HttpGet clone = (HttpGet) httpget.clone();
-
+
assertEquals(httpget.getMethod(), clone.getMethod());
assertEquals(httpget.getURI(), clone.getURI());
-
+
Header[] headers1 = httpget.getAllHeaders();
Header[] headers2 = clone.getAllHeaders();
-
+
assertTrue(LangUtils.equals(headers1, headers2));
assertTrue(httpget.getParams() != clone.getParams());
-
+
assertEquals(Integer.valueOf(1), clone.getParams().getParameter("p1"));
assertEquals("whatever", clone.getParams().getParameter("p2"));
assertEquals(null, clone.getParams().getParameter("p3"));
}
-
+
public void testCloneEntityEnclosingRequests() throws Exception {
HttpPost httppost = new HttpPost("http://host/path");
httppost.addHeader("h1", "this header");
@@ -104,32 +104,32 @@ public class TestHttpRequestBase extends
httppost.getParams().setParameter("p1", Integer.valueOf(1));
httppost.getParams().setParameter("p2", "whatever");
HttpPost clone = (HttpPost) httppost.clone();
-
+
assertEquals(httppost.getMethod(), clone.getMethod());
assertEquals(httppost.getURI(), clone.getURI());
-
+
Header[] headers1 = httppost.getAllHeaders();
Header[] headers2 = clone.getAllHeaders();
-
+
assertTrue(LangUtils.equals(headers1, headers2));
assertTrue(httppost.getParams() != clone.getParams());
-
+
assertEquals(Integer.valueOf(1), clone.getParams().getParameter("p1"));
assertEquals("whatever", clone.getParams().getParameter("p2"));
assertEquals(null, clone.getParams().getParameter("p3"));
-
+
assertNull(clone.getEntity());
-
+
StringEntity e1 = new StringEntity("stuff");
httppost.setEntity(e1);
clone = (HttpPost) httppost.clone();
assertTrue(clone.getEntity() instanceof StringEntity);
assertFalse(clone.getEntity().equals(e1));
-
- ByteArrayInputStream instream = new ByteArrayInputStream(new byte[] {});
+
+ ByteArrayInputStream instream = new ByteArrayInputStream(new byte[] {});
InputStreamEntity e2 = new InputStreamEntity(instream, -1);
httppost.setEntity(e2);
-
+
try {
httppost.clone();
fail("CloneNotSupportedException should have been thrown");
Modified: httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/client/protocol/TestCookie2Support.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/client/protocol/TestCookie2Support.java?rev=937479&r1=937478&r2=937479&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/client/protocol/TestCookie2Support.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/client/protocol/TestCookie2Support.java Fri Apr 23 19:19:23 2010
@@ -85,12 +85,12 @@ public class TestCookie2Support extends
localServer.registerDefaultHandlers();
localServer.start();
}
-
+
private static class CookieVer0Service implements HttpRequestHandler {
public void handle(
- final HttpRequest request,
- final HttpResponse response,
+ final HttpRequest request,
+ final HttpResponse response,
final HttpContext context) throws HttpException, IOException {
ProtocolVersion httpversion = request.getRequestLine().getProtocolVersion();
response.setStatusLine(httpversion, HttpStatus.SC_OK);
@@ -100,25 +100,25 @@ public class TestCookie2Support extends
}
}
-
+
public void testCookieVersionSupportHeader1() throws Exception {
this.localServer.register("*", new CookieVer0Service());
-
- DefaultHttpClient client = new DefaultHttpClient();
+
+ DefaultHttpClient client = new DefaultHttpClient();
client.getParams().setParameter(ClientPNames.COOKIE_POLICY, CookiePolicy.BEST_MATCH);
CookieStore cookieStore = new BasicCookieStore();
HttpContext context = new BasicHttpContext();
context.setAttribute(ClientContext.COOKIE_STORE, cookieStore);
-
+
HttpGet httpget = new HttpGet("/test/");
-
+
HttpResponse response1 = client.execute(getServerHttp(), httpget, context);
HttpEntity e1 = response1.getEntity();
if (e1 != null) {
e1.consumeContent();
}
-
+
List<Cookie> cookies = cookieStore.getCookies();
assertNotNull(cookies);
assertEquals(1, cookies.size());
@@ -128,19 +128,19 @@ public class TestCookie2Support extends
if (e2 != null) {
e2.consumeContent();
}
-
+
HttpRequest reqWrapper = (HttpRequest) context.getAttribute(ExecutionContext.HTTP_REQUEST);
-
+
Header cookiesupport = reqWrapper.getFirstHeader("Cookie2");
assertNotNull(cookiesupport);
assertEquals("$Version=1", cookiesupport.getValue());
}
-
+
private static class CookieVer1Service implements HttpRequestHandler {
public void handle(
- final HttpRequest request,
- final HttpResponse response,
+ final HttpRequest request,
+ final HttpResponse response,
final HttpContext context) throws HttpException, IOException {
ProtocolVersion httpversion = request.getRequestLine().getProtocolVersion();
response.setStatusLine(httpversion, HttpStatus.SC_OK);
@@ -151,25 +151,25 @@ public class TestCookie2Support extends
}
}
-
+
public void testCookieVersionSupportHeader2() throws Exception {
this.localServer.register("*", new CookieVer1Service());
-
- DefaultHttpClient client = new DefaultHttpClient();
+
+ DefaultHttpClient client = new DefaultHttpClient();
client.getParams().setParameter(ClientPNames.COOKIE_POLICY, CookiePolicy.BEST_MATCH);
CookieStore cookieStore = new BasicCookieStore();
HttpContext context = new BasicHttpContext();
context.setAttribute(ClientContext.COOKIE_STORE, cookieStore);
-
+
HttpGet httpget = new HttpGet("/test/");
-
+
HttpResponse response1 = client.execute(getServerHttp(), httpget, context);
HttpEntity e1 = response1.getEntity();
if (e1 != null) {
e1.consumeContent();
}
-
+
List<Cookie> cookies = cookieStore.getCookies();
assertNotNull(cookies);
assertEquals(2, cookies.size());
@@ -179,9 +179,9 @@ public class TestCookie2Support extends
if (e2 != null) {
e2.consumeContent();
}
-
+
HttpRequest reqWrapper = (HttpRequest) context.getAttribute(ExecutionContext.HTTP_REQUEST);
-
+
Header cookiesupport = reqWrapper.getFirstHeader(SM.COOKIE2);
assertNotNull(cookiesupport);
assertEquals("$Version=1", cookiesupport.getValue());
@@ -190,8 +190,8 @@ public class TestCookie2Support extends
private static class CookieVer2Service implements HttpRequestHandler {
public void handle(
- final HttpRequest request,
- final HttpResponse response,
+ final HttpRequest request,
+ final HttpResponse response,
final HttpContext context) throws HttpException, IOException {
ProtocolVersion httpversion = request.getRequestLine().getProtocolVersion();
response.setStatusLine(httpversion, HttpStatus.SC_OK);
@@ -201,25 +201,25 @@ public class TestCookie2Support extends
}
}
-
+
public void testCookieVersionSupportHeader3() throws Exception {
this.localServer.register("*", new CookieVer2Service());
-
- DefaultHttpClient client = new DefaultHttpClient();
+
+ DefaultHttpClient client = new DefaultHttpClient();
client.getParams().setParameter(ClientPNames.COOKIE_POLICY, CookiePolicy.BEST_MATCH);
CookieStore cookieStore = new BasicCookieStore();
HttpContext context = new BasicHttpContext();
context.setAttribute(ClientContext.COOKIE_STORE, cookieStore);
-
+
HttpGet httpget = new HttpGet("/test/");
-
+
HttpResponse response1 = client.execute(getServerHttp(), httpget, context);
HttpEntity e1 = response1.getEntity();
if (e1 != null) {
e1.consumeContent();
}
-
+
List<Cookie> cookies = cookieStore.getCookies();
assertNotNull(cookies);
assertEquals(1, cookies.size());
@@ -229,9 +229,9 @@ public class TestCookie2Support extends
if (e2 != null) {
e2.consumeContent();
}
-
+
HttpRequest reqWrapper = (HttpRequest) context.getAttribute(ExecutionContext.HTTP_REQUEST);
-
+
Header cookiesupport = reqWrapper.getFirstHeader("Cookie2");
assertNotNull(cookiesupport);
assertEquals("$Version=1", cookiesupport.getValue());
@@ -240,8 +240,8 @@ public class TestCookie2Support extends
private static class SetCookieVersionMixService implements HttpRequestHandler {
public void handle(
- final HttpRequest request,
- final HttpResponse response,
+ final HttpRequest request,
+ final HttpResponse response,
final HttpContext context) throws HttpException, IOException {
ProtocolVersion httpversion = request.getRequestLine().getProtocolVersion();
response.setStatusLine(httpversion, HttpStatus.SC_OK);
@@ -252,25 +252,25 @@ public class TestCookie2Support extends
}
}
-
+
public void testSetCookieVersionMix() throws Exception {
this.localServer.register("*", new SetCookieVersionMixService());
-
- DefaultHttpClient client = new DefaultHttpClient();
+
+ DefaultHttpClient client = new DefaultHttpClient();
client.getParams().setParameter(ClientPNames.COOKIE_POLICY, CookiePolicy.BEST_MATCH);
CookieStore cookieStore = new BasicCookieStore();
HttpContext context = new BasicHttpContext();
context.setAttribute(ClientContext.COOKIE_STORE, cookieStore);
-
+
HttpGet httpget = new HttpGet("/test/");
-
+
HttpResponse response1 = client.execute(getServerHttp(), httpget, context);
HttpEntity e1 = response1.getEntity();
if (e1 != null) {
e1.consumeContent();
}
-
+
List<Cookie> cookies = cookieStore.getCookies();
assertNotNull(cookies);
assertEquals(1, cookies.size());