From fe175a845a970f7495a01102e7a10a68f88a7dc3 Mon Sep 17 00:00:00 2001 From: Oleg Kalnichevski Date: Sat, 4 Jul 2015 13:43:20 +0000 Subject: [PATCH] Removed AUTH and SM classes git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk@1689156 13f79535-47bb-0310-9956-ffa450edef68 --- .../impl/auth/win/WindowsNegotiateScheme.java | 6 +- .../auth/win/TestWindowsNegotiateScheme.java | 4 +- .../main/java/org/apache/http/auth/AUTH.java | 64 ------------------- .../protocol/ResponseProcessCookies.java | 3 +- .../main/java/org/apache/http/cookie/SM.java | 41 ------------ .../apache/http/impl/auth/BasicScheme.java | 6 +- .../apache/http/impl/auth/DigestScheme.java | 6 +- .../apache/http/impl/auth/GGSSchemeBase.java | 6 +- .../org/apache/http/impl/auth/NTLMScheme.java | 6 +- .../apache/http/impl/client/ProxyClient.java | 4 +- .../http/impl/cookie/RFC6265CookieSpec.java | 5 +- .../http/impl/execchain/MainClientExec.java | 16 ++--- .../protocol/TestRequestAddCookies.java | 21 +++--- .../protocol/TestResponseProcessCookies.java | 9 ++- .../http/impl/auth/TestBasicScheme.java | 6 +- .../http/impl/auth/TestHttpAuthenticator.java | 63 +++++++++--------- .../client/TestAuthenticationStrategy.java | 2 +- .../integration/TestClientAuthentication.java | 4 +- .../TestClientAuthenticationFallBack.java | 6 +- .../TestClientReauthentication.java | 4 +- .../client/integration/TestRedirects.java | 3 +- .../localserver/BasicAuthTokenExtractor.java | 4 +- .../ResponseBasicUnauthorized.java | 6 +- 23 files changed, 92 insertions(+), 203 deletions(-) delete mode 100644 httpclient/src/main/java/org/apache/http/auth/AUTH.java delete mode 100644 httpclient/src/main/java/org/apache/http/cookie/SM.java diff --git a/httpclient-win/src/main/java/org/apache/http/impl/auth/win/WindowsNegotiateScheme.java b/httpclient-win/src/main/java/org/apache/http/impl/auth/win/WindowsNegotiateScheme.java index 02f21cefb..1ef9c46a6 100644 --- a/httpclient-win/src/main/java/org/apache/http/impl/auth/win/WindowsNegotiateScheme.java +++ b/httpclient-win/src/main/java/org/apache/http/impl/auth/win/WindowsNegotiateScheme.java @@ -30,10 +30,10 @@ import org.apache.commons.codec.binary.Base64; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.http.Header; +import org.apache.http.HttpHeaders; import org.apache.http.HttpHost; import org.apache.http.HttpRequest; import org.apache.http.annotation.NotThreadSafe; -import org.apache.http.auth.AUTH; import org.apache.http.auth.AuthChallenge; import org.apache.http.auth.AuthenticationException; import org.apache.http.auth.ChallengeType; @@ -205,9 +205,9 @@ public class WindowsNegotiateScheme extends NonStandardAuthScheme { final CharArrayBuffer buffer = new CharArrayBuffer(scheme.length() + 30); if (isProxy()) { - buffer.append(AUTH.PROXY_AUTH_RESP); + buffer.append(HttpHeaders.PROXY_AUTHORIZATION); } else { - buffer.append(AUTH.WWW_AUTH_RESP); + buffer.append(HttpHeaders.AUTHORIZATION); } buffer.append(": "); buffer.append(scheme); // NTLM or Negotiate diff --git a/httpclient-win/src/test/java/org/apache/http/impl/auth/win/TestWindowsNegotiateScheme.java b/httpclient-win/src/test/java/org/apache/http/impl/auth/win/TestWindowsNegotiateScheme.java index f3b3f932e..fb28d5cd7 100644 --- a/httpclient-win/src/test/java/org/apache/http/impl/auth/win/TestWindowsNegotiateScheme.java +++ b/httpclient-win/src/test/java/org/apache/http/impl/auth/win/TestWindowsNegotiateScheme.java @@ -29,11 +29,11 @@ package org.apache.http.impl.auth.win; import java.io.IOException; import org.apache.http.HttpException; +import org.apache.http.HttpHeaders; import org.apache.http.HttpHost; import org.apache.http.HttpRequest; import org.apache.http.HttpResponse; import org.apache.http.HttpStatus; -import org.apache.http.auth.AUTH; import org.apache.http.auth.AuthScheme; import org.apache.http.auth.AuthSchemeProvider; import org.apache.http.auth.CredentialsProvider; @@ -75,7 +75,7 @@ public class TestWindowsNegotiateScheme extends LocalServerTestBase { final HttpRequest request, final HttpResponse response, final HttpContext context) throws HttpException, IOException { - response.addHeader(AUTH.WWW_AUTH, AuthSchemes.SPNEGO); + response.addHeader(HttpHeaders.WWW_AUTHENTICATE, AuthSchemes.SPNEGO); response.setStatusCode(HttpStatus.SC_UNAUTHORIZED); } diff --git a/httpclient/src/main/java/org/apache/http/auth/AUTH.java b/httpclient/src/main/java/org/apache/http/auth/AUTH.java deleted file mode 100644 index 8ae454533..000000000 --- a/httpclient/src/main/java/org/apache/http/auth/AUTH.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * ==================================================================== - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * . - * - */ - -package org.apache.http.auth; - -import org.apache.http.annotation.Immutable; - -/** - * Constants and static helpers related to the HTTP authentication. - * - * - * @since 4.0 - */ -@Immutable -public final class AUTH { - - /** - * The www authenticate challange header. - */ - public static final String WWW_AUTH = "WWW-Authenticate"; - - /** - * The www authenticate response header. - */ - public static final String WWW_AUTH_RESP = "Authorization"; - - /** - * The proxy authenticate challange header. - */ - public static final String PROXY_AUTH = "Proxy-Authenticate"; - - /** - * The proxy authenticate response header. - */ - public static final String PROXY_AUTH_RESP = "Proxy-Authorization"; - - private AUTH() { - } - -} diff --git a/httpclient/src/main/java/org/apache/http/client/protocol/ResponseProcessCookies.java b/httpclient/src/main/java/org/apache/http/client/protocol/ResponseProcessCookies.java index 8a3964914..e99840cc9 100644 --- a/httpclient/src/main/java/org/apache/http/client/protocol/ResponseProcessCookies.java +++ b/httpclient/src/main/java/org/apache/http/client/protocol/ResponseProcessCookies.java @@ -43,7 +43,6 @@ import org.apache.http.cookie.Cookie; import org.apache.http.cookie.CookieOrigin; import org.apache.http.cookie.CookieSpec; import org.apache.http.cookie.MalformedCookieException; -import org.apache.http.cookie.SM; import org.apache.http.protocol.HttpContext; import org.apache.http.util.Args; @@ -88,7 +87,7 @@ public class ResponseProcessCookies implements HttpResponseInterceptor { this.log.debug("Cookie origin not specified in HTTP context"); return; } - final HeaderIterator it = response.headerIterator(SM.SET_COOKIE); + final HeaderIterator it = response.headerIterator("Set-Cookie"); processCookies(it, cookieSpec, cookieOrigin, cookieStore); } diff --git a/httpclient/src/main/java/org/apache/http/cookie/SM.java b/httpclient/src/main/java/org/apache/http/cookie/SM.java deleted file mode 100644 index d4b302dab..000000000 --- a/httpclient/src/main/java/org/apache/http/cookie/SM.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * ==================================================================== - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * . - * - */ - -package org.apache.http.cookie; - -/** - * Constants and static helpers related to the HTTP state management. - * - * - * @since 4.0 - */ -public interface SM { - - public static final String COOKIE = "Cookie"; - public static final String SET_COOKIE = "Set-Cookie"; - -} diff --git a/httpclient/src/main/java/org/apache/http/impl/auth/BasicScheme.java b/httpclient/src/main/java/org/apache/http/impl/auth/BasicScheme.java index 0817784c7..509b4a1f1 100644 --- a/httpclient/src/main/java/org/apache/http/impl/auth/BasicScheme.java +++ b/httpclient/src/main/java/org/apache/http/impl/auth/BasicScheme.java @@ -35,9 +35,9 @@ import java.nio.charset.Charset; import org.apache.commons.codec.binary.Base64; import org.apache.http.Consts; import org.apache.http.Header; +import org.apache.http.HttpHeaders; import org.apache.http.HttpRequest; import org.apache.http.annotation.NotThreadSafe; -import org.apache.http.auth.AUTH; import org.apache.http.auth.AuthChallenge; import org.apache.http.auth.AuthenticationException; import org.apache.http.auth.ChallengeType; @@ -107,9 +107,9 @@ public class BasicScheme extends StandardAuthScheme { Args.notNull(request, "HTTP request"); final CharArrayBuffer buffer = new CharArrayBuffer(32); if (isProxy()) { - buffer.append(AUTH.PROXY_AUTH_RESP); + buffer.append(HttpHeaders.PROXY_AUTHORIZATION); } else { - buffer.append(AUTH.WWW_AUTH_RESP); + buffer.append(HttpHeaders.AUTHORIZATION); } buffer.append(": Basic "); diff --git a/httpclient/src/main/java/org/apache/http/impl/auth/DigestScheme.java b/httpclient/src/main/java/org/apache/http/impl/auth/DigestScheme.java index 9c9f8b3bc..c4d598139 100644 --- a/httpclient/src/main/java/org/apache/http/impl/auth/DigestScheme.java +++ b/httpclient/src/main/java/org/apache/http/impl/auth/DigestScheme.java @@ -40,9 +40,9 @@ import java.util.StringTokenizer; import org.apache.http.Header; import org.apache.http.HttpEntity; import org.apache.http.HttpEntityEnclosingRequest; +import org.apache.http.HttpHeaders; import org.apache.http.HttpRequest; import org.apache.http.annotation.NotThreadSafe; -import org.apache.http.auth.AUTH; import org.apache.http.auth.AuthChallenge; import org.apache.http.auth.AuthenticationException; import org.apache.http.auth.ChallengeType; @@ -324,9 +324,9 @@ public class DigestScheme extends StandardAuthScheme { final CharArrayBuffer buffer = new CharArrayBuffer(128); if (isProxy()) { - buffer.append(AUTH.PROXY_AUTH_RESP); + buffer.append(HttpHeaders.PROXY_AUTHORIZATION); } else { - buffer.append(AUTH.WWW_AUTH_RESP); + buffer.append(HttpHeaders.AUTHORIZATION); } buffer.append(": Digest "); diff --git a/httpclient/src/main/java/org/apache/http/impl/auth/GGSSchemeBase.java b/httpclient/src/main/java/org/apache/http/impl/auth/GGSSchemeBase.java index 35ac3766f..a2f432f51 100644 --- a/httpclient/src/main/java/org/apache/http/impl/auth/GGSSchemeBase.java +++ b/httpclient/src/main/java/org/apache/http/impl/auth/GGSSchemeBase.java @@ -33,10 +33,10 @@ import org.apache.commons.codec.binary.Base64; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.http.Header; +import org.apache.http.HttpHeaders; import org.apache.http.HttpHost; import org.apache.http.HttpRequest; import org.apache.http.annotation.NotThreadSafe; -import org.apache.http.auth.AUTH; import org.apache.http.auth.AuthChallenge; import org.apache.http.auth.AuthenticationException; import org.apache.http.auth.ChallengeType; @@ -235,9 +235,9 @@ public abstract class GGSSchemeBase extends NonStandardAuthScheme { } final CharArrayBuffer buffer = new CharArrayBuffer(32); if (isProxy()) { - buffer.append(AUTH.PROXY_AUTH_RESP); + buffer.append(HttpHeaders.PROXY_AUTHORIZATION); } else { - buffer.append(AUTH.WWW_AUTH_RESP); + buffer.append(HttpHeaders.AUTHORIZATION); } buffer.append(": Negotiate "); buffer.append(tokenstr); diff --git a/httpclient/src/main/java/org/apache/http/impl/auth/NTLMScheme.java b/httpclient/src/main/java/org/apache/http/impl/auth/NTLMScheme.java index 3e509e71f..2b363996d 100644 --- a/httpclient/src/main/java/org/apache/http/impl/auth/NTLMScheme.java +++ b/httpclient/src/main/java/org/apache/http/impl/auth/NTLMScheme.java @@ -27,9 +27,9 @@ package org.apache.http.impl.auth; import org.apache.http.Header; +import org.apache.http.HttpHeaders; import org.apache.http.HttpRequest; import org.apache.http.annotation.NotThreadSafe; -import org.apache.http.auth.AUTH; import org.apache.http.auth.AuthChallenge; import org.apache.http.auth.AuthenticationException; import org.apache.http.auth.ChallengeType; @@ -144,9 +144,9 @@ public class NTLMScheme extends NonStandardAuthScheme { } final CharArrayBuffer buffer = new CharArrayBuffer(32); if (isProxy()) { - buffer.append(AUTH.PROXY_AUTH_RESP); + buffer.append(HttpHeaders.PROXY_AUTHORIZATION); } else { - buffer.append(AUTH.WWW_AUTH_RESP); + buffer.append(HttpHeaders.AUTHORIZATION); } buffer.append(": NTLM "); buffer.append(response); diff --git a/httpclient/src/main/java/org/apache/http/impl/client/ProxyClient.java b/httpclient/src/main/java/org/apache/http/impl/client/ProxyClient.java index dc2dc3178..e68b47ce2 100644 --- a/httpclient/src/main/java/org/apache/http/impl/client/ProxyClient.java +++ b/httpclient/src/main/java/org/apache/http/impl/client/ProxyClient.java @@ -33,11 +33,11 @@ import java.net.Socket; import org.apache.http.ConnectionReuseStrategy; import org.apache.http.HttpEntity; import org.apache.http.HttpException; +import org.apache.http.HttpHeaders; import org.apache.http.HttpHost; import org.apache.http.HttpRequest; import org.apache.http.HttpResponse; import org.apache.http.HttpVersion; -import org.apache.http.auth.AUTH; import org.apache.http.auth.AuthSchemeProvider; import org.apache.http.auth.AuthScope; import org.apache.http.auth.AuthState; @@ -198,7 +198,7 @@ public class ProxyClient { conn.close(); } // discard previous auth header - connect.removeHeaders(AUTH.PROXY_AUTH_RESP); + connect.removeHeaders(HttpHeaders.PROXY_AUTHORIZATION); } else { break; } diff --git a/httpclient/src/main/java/org/apache/http/impl/cookie/RFC6265CookieSpec.java b/httpclient/src/main/java/org/apache/http/impl/cookie/RFC6265CookieSpec.java index af182e97d..05fce8773 100644 --- a/httpclient/src/main/java/org/apache/http/impl/cookie/RFC6265CookieSpec.java +++ b/httpclient/src/main/java/org/apache/http/impl/cookie/RFC6265CookieSpec.java @@ -47,7 +47,6 @@ import org.apache.http.cookie.CookieOrigin; import org.apache.http.cookie.CookiePriorityComparator; import org.apache.http.cookie.CookieSpec; import org.apache.http.cookie.MalformedCookieException; -import org.apache.http.cookie.SM; import org.apache.http.message.BufferedHeader; import org.apache.http.message.ParserCursor; import org.apache.http.message.TokenParser; @@ -110,7 +109,7 @@ public class RFC6265CookieSpec implements CookieSpec { public final List parse(final Header header, final CookieOrigin origin) throws MalformedCookieException { Args.notNull(header, "Header"); Args.notNull(origin, "Cookie origin"); - if (!header.getName().equalsIgnoreCase(SM.SET_COOKIE)) { + if (!header.getName().equalsIgnoreCase("Set-Cookie")) { throw new MalformedCookieException("Unrecognized cookie header: '" + header.toString() + "'"); } final CharArrayBuffer buffer; @@ -217,7 +216,7 @@ public class RFC6265CookieSpec implements CookieSpec { sortedCookies = cookies; } final CharArrayBuffer buffer = new CharArrayBuffer(20 * sortedCookies.size()); - buffer.append(SM.COOKIE); + buffer.append("Cookie"); buffer.append(": "); for (int n = 0; n < sortedCookies.size(); n++) { final Cookie cookie = sortedCookies.get(n); diff --git a/httpclient/src/main/java/org/apache/http/impl/execchain/MainClientExec.java b/httpclient/src/main/java/org/apache/http/impl/execchain/MainClientExec.java index 7bf79fcb0..fb457fee1 100644 --- a/httpclient/src/main/java/org/apache/http/impl/execchain/MainClientExec.java +++ b/httpclient/src/main/java/org/apache/http/impl/execchain/MainClientExec.java @@ -39,11 +39,11 @@ import org.apache.http.HttpClientConnection; import org.apache.http.HttpEntity; import org.apache.http.HttpEntityEnclosingRequest; import org.apache.http.HttpException; +import org.apache.http.HttpHeaders; import org.apache.http.HttpHost; import org.apache.http.HttpRequest; import org.apache.http.HttpResponse; import org.apache.http.annotation.Immutable; -import org.apache.http.auth.AUTH; import org.apache.http.auth.AuthProtocolState; import org.apache.http.auth.AuthState; import org.apache.http.auth.ChallengeType; @@ -244,13 +244,13 @@ public class MainClientExec implements ClientExecChain { this.log.debug("Executing request " + request.getRequestLine()); } - if (!request.containsHeader(AUTH.WWW_AUTH_RESP)) { + if (!request.containsHeader(HttpHeaders.AUTHORIZATION)) { if (this.log.isDebugEnabled()) { this.log.debug("Target auth state: " + targetAuthState.getState()); } this.authenticator.generateAuthResponse(request, targetAuthState, context); } - if (!request.containsHeader(AUTH.PROXY_AUTH_RESP) && !route.isTunnelled()) { + if (!request.containsHeader(HttpHeaders.PROXY_AUTHORIZATION) && !route.isTunnelled()) { if (this.log.isDebugEnabled()) { this.log.debug("Proxy auth state: " + proxyAuthState.getState()); } @@ -306,11 +306,11 @@ public class MainClientExec implements ClientExecChain { } // discard previous auth headers final HttpRequest original = request.getOriginal(); - if (!original.containsHeader(AUTH.WWW_AUTH_RESP)) { - request.removeHeaders(AUTH.WWW_AUTH_RESP); + if (!original.containsHeader(HttpHeaders.AUTHORIZATION)) { + request.removeHeaders(HttpHeaders.AUTHORIZATION); } - if (!original.containsHeader(AUTH.PROXY_AUTH_RESP)) { - request.removeHeaders(AUTH.PROXY_AUTH_RESP); + if (!original.containsHeader(HttpHeaders.PROXY_AUTHORIZATION)) { + request.removeHeaders(HttpHeaders.PROXY_AUTHORIZATION); } } else { break; @@ -454,7 +454,7 @@ public class MainClientExec implements ClientExecChain { context); } - connect.removeHeaders(AUTH.PROXY_AUTH_RESP); + connect.removeHeaders(HttpHeaders.PROXY_AUTHORIZATION); this.authenticator.generateAuthResponse(connect, proxyAuthState, context); response = this.requestExecutor.execute(connect, managedConn, context); diff --git a/httpclient/src/test/java/org/apache/http/client/protocol/TestRequestAddCookies.java b/httpclient/src/test/java/org/apache/http/client/protocol/TestRequestAddCookies.java index 1379b180d..e3079f246 100644 --- a/httpclient/src/test/java/org/apache/http/client/protocol/TestRequestAddCookies.java +++ b/httpclient/src/test/java/org/apache/http/client/protocol/TestRequestAddCookies.java @@ -43,7 +43,6 @@ import org.apache.http.conn.routing.RouteInfo.TunnelType; import org.apache.http.cookie.CookieOrigin; import org.apache.http.cookie.CookieSpec; import org.apache.http.cookie.CookieSpecProvider; -import org.apache.http.cookie.SM; import org.apache.http.impl.client.BasicCookieStore; import org.apache.http.impl.cookie.BasicClientCookie; import org.apache.http.impl.cookie.IgnoreSpecProvider; @@ -116,7 +115,7 @@ public class TestRequestAddCookies { final HttpRequestInterceptor interceptor = new RequestAddCookies(); interceptor.process(request, context); - final Header[] headers = request.getHeaders(SM.COOKIE); + final Header[] headers = request.getHeaders("Cookie"); Assert.assertNotNull(headers); Assert.assertEquals(1, headers.length); Assert.assertEquals("name1=value1; name2=value2", headers[0].getValue()); @@ -144,7 +143,7 @@ public class TestRequestAddCookies { final HttpRequestInterceptor interceptor = new RequestAddCookies(); interceptor.process(request, context); - final Header[] headers = request.getHeaders(SM.COOKIE); + final Header[] headers = request.getHeaders("Cookie"); Assert.assertNotNull(headers); Assert.assertEquals(0, headers.length); } @@ -164,7 +163,7 @@ public class TestRequestAddCookies { final HttpRequestInterceptor interceptor = new RequestAddCookies(); interceptor.process(request, context); - final Header[] headers = request.getHeaders(SM.COOKIE); + final Header[] headers = request.getHeaders("Cookie"); Assert.assertNotNull(headers); Assert.assertEquals(0, headers.length); } @@ -184,7 +183,7 @@ public class TestRequestAddCookies { final HttpRequestInterceptor interceptor = new RequestAddCookies(); interceptor.process(request, context); - final Header[] headers = request.getHeaders(SM.COOKIE); + final Header[] headers = request.getHeaders("Cookie"); Assert.assertNotNull(headers); Assert.assertEquals(0, headers.length); } @@ -204,7 +203,7 @@ public class TestRequestAddCookies { final HttpRequestInterceptor interceptor = new RequestAddCookies(); interceptor.process(request, context); - final Header[] headers = request.getHeaders(SM.COOKIE); + final Header[] headers = request.getHeaders("Cookie"); Assert.assertNotNull(headers); Assert.assertEquals(0, headers.length); } @@ -222,7 +221,7 @@ public class TestRequestAddCookies { final HttpRequestInterceptor interceptor = new RequestAddCookies(); interceptor.process(request, context); - final Header[] headers = request.getHeaders(SM.COOKIE); + final Header[] headers = request.getHeaders("Cookie"); Assert.assertNotNull(headers); Assert.assertEquals(0, headers.length); } @@ -247,7 +246,7 @@ public class TestRequestAddCookies { final CookieSpec cookieSpec = context.getCookieSpec(); Assert.assertTrue(cookieSpec instanceof RFC6265StrictSpec); - final Header[] headers1 = request.getHeaders(SM.COOKIE); + final Header[] headers1 = request.getHeaders("Cookie"); Assert.assertNotNull(headers1); Assert.assertEquals(1, headers1.length); Assert.assertEquals("name1=value1; name2=value2", headers1[0].getValue()); @@ -372,7 +371,7 @@ public class TestRequestAddCookies { final HttpRequestInterceptor interceptor = new RequestAddCookies(); interceptor.process(request, context); - final Header[] headers = request.getHeaders(SM.COOKIE); + final Header[] headers = request.getHeaders("Cookie"); Assert.assertNotNull(headers); Assert.assertEquals(1, headers.length); Assert.assertEquals("name1=value1; name2=value2", headers[0].getValue()); @@ -401,7 +400,7 @@ public class TestRequestAddCookies { final HttpRequestInterceptor interceptor = new RequestAddCookies(); interceptor.process(request, context); - final Header[] headers = request.getHeaders(SM.COOKIE); + final Header[] headers = request.getHeaders("Cookie"); Assert.assertNotNull(headers); Assert.assertEquals(0, headers.length); } @@ -437,7 +436,7 @@ public class TestRequestAddCookies { final HttpRequestInterceptor interceptor = new RequestAddCookies(); interceptor.process(request, context); - final Header[] headers1 = request.getHeaders(SM.COOKIE); + final Header[] headers1 = request.getHeaders("Cookie"); Assert.assertNotNull(headers1); Assert.assertEquals(1, headers1.length); diff --git a/httpclient/src/test/java/org/apache/http/client/protocol/TestResponseProcessCookies.java b/httpclient/src/test/java/org/apache/http/client/protocol/TestResponseProcessCookies.java index fd241fd97..e639bdaa4 100644 --- a/httpclient/src/test/java/org/apache/http/client/protocol/TestResponseProcessCookies.java +++ b/httpclient/src/test/java/org/apache/http/client/protocol/TestResponseProcessCookies.java @@ -35,7 +35,6 @@ import org.apache.http.client.CookieStore; import org.apache.http.cookie.Cookie; import org.apache.http.cookie.CookieOrigin; import org.apache.http.cookie.CookieSpec; -import org.apache.http.cookie.SM; import org.apache.http.impl.client.BasicCookieStore; import org.apache.http.impl.cookie.RFC6265LaxSpec; import org.apache.http.message.BasicHttpResponse; @@ -73,7 +72,7 @@ public class TestResponseProcessCookies { @Test public void testParseCookies() throws Exception { final HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK"); - response.addHeader(SM.SET_COOKIE, "name1=value1"); + response.addHeader("Set-Cookie", "name1=value1"); final HttpClientContext context = HttpClientContext.create(); context.setAttribute(HttpClientContext.COOKIE_ORIGIN, this.cookieOrigin); @@ -96,7 +95,7 @@ public class TestResponseProcessCookies { @Test public void testNoCookieOrigin() throws Exception { final HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK"); - response.addHeader(SM.SET_COOKIE, "name1=value1"); + response.addHeader("Set-Cookie", "name1=value1"); final HttpClientContext context = HttpClientContext.create(); context.setAttribute(HttpClientContext.COOKIE_ORIGIN, null); @@ -114,7 +113,7 @@ public class TestResponseProcessCookies { @Test public void testNoCookieSpec() throws Exception { final HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK"); - response.addHeader(SM.SET_COOKIE, "name1=value1"); + response.addHeader("Set-Cookie", "name1=value1"); final HttpClientContext context = HttpClientContext.create(); context.setAttribute(HttpClientContext.COOKIE_ORIGIN, this.cookieOrigin); @@ -132,7 +131,7 @@ public class TestResponseProcessCookies { @Test public void testNoCookieStore() throws Exception { final HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK"); - response.addHeader(SM.SET_COOKIE, "name1=value1"); + response.addHeader("Set-Cookie", "name1=value1"); final HttpClientContext context = HttpClientContext.create(); context.setAttribute(HttpClientContext.COOKIE_ORIGIN, this.cookieOrigin); diff --git a/httpclient/src/test/java/org/apache/http/impl/auth/TestBasicScheme.java b/httpclient/src/test/java/org/apache/http/impl/auth/TestBasicScheme.java index 99c3ad77e..63fdf9431 100644 --- a/httpclient/src/test/java/org/apache/http/impl/auth/TestBasicScheme.java +++ b/httpclient/src/test/java/org/apache/http/impl/auth/TestBasicScheme.java @@ -35,8 +35,8 @@ import java.util.List; import org.apache.commons.codec.binary.Base64; import org.apache.http.Consts; import org.apache.http.Header; +import org.apache.http.HttpHeaders; import org.apache.http.HttpRequest; -import org.apache.http.auth.AUTH; import org.apache.http.auth.AuthChallenge; import org.apache.http.auth.AuthScheme; import org.apache.http.auth.ChallengeType; @@ -105,7 +105,7 @@ public class TestBasicScheme { final String expected = "Basic " + EncodingUtils.getAsciiString( Base64.encodeBase64(EncodingUtils.getAsciiBytes("testuser:testpass"))); - Assert.assertEquals(AUTH.WWW_AUTH_RESP, authResponse.getName()); + Assert.assertEquals(HttpHeaders.AUTHORIZATION, authResponse.getName()); Assert.assertEquals(expected, authResponse.getValue()); Assert.assertEquals("test", authscheme.getRealm()); Assert.assertTrue(authscheme.isComplete()); @@ -127,7 +127,7 @@ public class TestBasicScheme { final String expected = "Basic " + EncodingUtils.getAsciiString( Base64.encodeBase64(EncodingUtils.getAsciiBytes("testuser:testpass"))); - Assert.assertEquals(AUTH.PROXY_AUTH_RESP, authResponse.getName()); + Assert.assertEquals(HttpHeaders.PROXY_AUTHORIZATION, authResponse.getName()); Assert.assertEquals(expected, authResponse.getValue()); Assert.assertEquals("test", authscheme.getRealm()); Assert.assertTrue(authscheme.isComplete()); diff --git a/httpclient/src/test/java/org/apache/http/impl/auth/TestHttpAuthenticator.java b/httpclient/src/test/java/org/apache/http/impl/auth/TestHttpAuthenticator.java index 227c30f25..a15e69ad3 100644 --- a/httpclient/src/test/java/org/apache/http/impl/auth/TestHttpAuthenticator.java +++ b/httpclient/src/test/java/org/apache/http/impl/auth/TestHttpAuthenticator.java @@ -35,7 +35,6 @@ import org.apache.http.HttpRequest; import org.apache.http.HttpResponse; import org.apache.http.HttpStatus; import org.apache.http.HttpVersion; -import org.apache.http.auth.AUTH; import org.apache.http.auth.AuthOption; import org.apache.http.auth.AuthProtocolState; import org.apache.http.auth.AuthScheme; @@ -160,9 +159,9 @@ public class TestHttpAuthenticator { public void testAuthentication() throws Exception { final HttpHost host = new HttpHost("somehost", 80); final HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, HttpStatus.SC_UNAUTHORIZED, "UNAUTHORIZED"); - response.addHeader(new BasicHeader(AUTH.WWW_AUTH, "Basic realm=\"test\"")); - response.addHeader(new BasicHeader(AUTH.WWW_AUTH, "Digest realm=\"realm1\", nonce=\"1234\"")); - response.addHeader(new BasicHeader(AUTH.WWW_AUTH, "whatever realm=\"realm1\", stuff=\"1234\"")); + response.addHeader(new BasicHeader(HttpHeaders.WWW_AUTHENTICATE, "Basic realm=\"test\"")); + response.addHeader(new BasicHeader(HttpHeaders.WWW_AUTHENTICATE, "Digest realm=\"realm1\", nonce=\"1234\"")); + response.addHeader(new BasicHeader(HttpHeaders.WWW_AUTHENTICATE, "whatever realm=\"realm1\", stuff=\"1234\"")); final DefaultAuthenticationStrategy authStrategy = new DefaultAuthenticationStrategy(); @@ -196,8 +195,8 @@ public class TestHttpAuthenticator { public void testAuthenticationNoSupportedChallenges() throws Exception { final HttpHost host = new HttpHost("somehost", 80); final HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, HttpStatus.SC_UNAUTHORIZED, "UNAUTHORIZED"); - response.addHeader(new BasicHeader(AUTH.WWW_AUTH, "This realm=\"test\"")); - response.addHeader(new BasicHeader(AUTH.WWW_AUTH, "That realm=\"realm1\", nonce=\"1234\"")); + response.addHeader(new BasicHeader(HttpHeaders.WWW_AUTHENTICATE, "This realm=\"test\"")); + response.addHeader(new BasicHeader(HttpHeaders.WWW_AUTHENTICATE, "That realm=\"realm1\", nonce=\"1234\"")); final DefaultAuthenticationStrategy authStrategy = new DefaultAuthenticationStrategy(); @@ -209,8 +208,8 @@ public class TestHttpAuthenticator { public void testAuthenticationNoCredentials() throws Exception { final HttpHost host = new HttpHost("somehost", 80); final HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, HttpStatus.SC_UNAUTHORIZED, "UNAUTHORIZED"); - response.addHeader(new BasicHeader(AUTH.WWW_AUTH, "Basic realm=\"test\"")); - response.addHeader(new BasicHeader(AUTH.WWW_AUTH, "Digest realm=\"realm1\", nonce=\"1234\"")); + response.addHeader(new BasicHeader(HttpHeaders.WWW_AUTHENTICATE, "Basic realm=\"test\"")); + response.addHeader(new BasicHeader(HttpHeaders.WWW_AUTHENTICATE, "Digest realm=\"realm1\", nonce=\"1234\"")); this.credentialsProvider.clear(); @@ -224,8 +223,8 @@ public class TestHttpAuthenticator { public void testAuthenticationFailed() throws Exception { final HttpHost host = new HttpHost("somehost", 80); final HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, HttpStatus.SC_UNAUTHORIZED, "UNAUTHORIZED"); - response.addHeader(new BasicHeader(AUTH.WWW_AUTH, "Basic realm=\"test\"")); - response.addHeader(new BasicHeader(AUTH.WWW_AUTH, "Digest realm=\"realm1\", nonce=\"1234\"")); + response.addHeader(new BasicHeader(HttpHeaders.WWW_AUTHENTICATE, "Basic realm=\"test\"")); + response.addHeader(new BasicHeader(HttpHeaders.WWW_AUTHENTICATE, "Digest realm=\"realm1\", nonce=\"1234\"")); this.authState.setState(AuthProtocolState.CHALLENGED); this.authState.update(this.authScheme, this.credentials); @@ -244,8 +243,8 @@ public class TestHttpAuthenticator { public void testAuthenticationFailedPreviously() throws Exception { final HttpHost host = new HttpHost("somehost", 80); final HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, HttpStatus.SC_UNAUTHORIZED, "UNAUTHORIZED"); - response.addHeader(new BasicHeader(AUTH.WWW_AUTH, "Basic realm=\"test\"")); - response.addHeader(new BasicHeader(AUTH.WWW_AUTH, "Digest realm=\"realm1\", nonce=\"1234\"")); + response.addHeader(new BasicHeader(HttpHeaders.WWW_AUTHENTICATE, "Basic realm=\"test\"")); + response.addHeader(new BasicHeader(HttpHeaders.WWW_AUTHENTICATE, "Digest realm=\"realm1\", nonce=\"1234\"")); this.authState.setState(AuthProtocolState.FAILURE); @@ -261,9 +260,9 @@ public class TestHttpAuthenticator { public void testAuthenticationFailure() throws Exception { final HttpHost host = new HttpHost("somehost", 80); final HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, HttpStatus.SC_UNAUTHORIZED, "UNAUTHORIZED"); - response.addHeader(new BasicHeader(AUTH.WWW_AUTH, "Basic realm=\"test\"")); - response.addHeader(new BasicHeader(AUTH.WWW_AUTH, "Digest realm=\"realm1\", nonce=\"1234\"")); - response.addHeader(new BasicHeader(AUTH.WWW_AUTH, "whatever realm=\"realm1\", stuff=\"1234\"")); + response.addHeader(new BasicHeader(HttpHeaders.WWW_AUTHENTICATE, "Basic realm=\"test\"")); + response.addHeader(new BasicHeader(HttpHeaders.WWW_AUTHENTICATE, "Digest realm=\"realm1\", nonce=\"1234\"")); + response.addHeader(new BasicHeader(HttpHeaders.WWW_AUTHENTICATE, "whatever realm=\"realm1\", stuff=\"1234\"")); final DefaultAuthenticationStrategy authStrategy = new DefaultAuthenticationStrategy(); @@ -280,9 +279,9 @@ public class TestHttpAuthenticator { public void testAuthenticationHandshaking() throws Exception { final HttpHost host = new HttpHost("somehost", 80); final HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, HttpStatus.SC_UNAUTHORIZED, "UNAUTHORIZED"); - response.addHeader(new BasicHeader(AUTH.WWW_AUTH, "Basic realm=\"test\"")); - response.addHeader(new BasicHeader(AUTH.WWW_AUTH, "Digest realm=\"realm1\", stale=true, nonce=\"1234\"")); - response.addHeader(new BasicHeader(AUTH.WWW_AUTH, "whatever realm=\"realm1\", stuff=\"1234\"")); + response.addHeader(new BasicHeader(HttpHeaders.WWW_AUTHENTICATE, "Basic realm=\"test\"")); + response.addHeader(new BasicHeader(HttpHeaders.WWW_AUTHENTICATE, "Digest realm=\"realm1\", stale=true, nonce=\"1234\"")); + response.addHeader(new BasicHeader(HttpHeaders.WWW_AUTHENTICATE, "whatever realm=\"realm1\", stuff=\"1234\"")); final DefaultAuthenticationStrategy authStrategy = new DefaultAuthenticationStrategy(); @@ -299,8 +298,8 @@ public class TestHttpAuthenticator { public void testAuthenticationNoMatchingChallenge() throws Exception { final HttpHost host = new HttpHost("somehost", 80); final HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, HttpStatus.SC_UNAUTHORIZED, "UNAUTHORIZED"); - response.addHeader(new BasicHeader(AUTH.WWW_AUTH, "Digest realm=\"realm1\", nonce=\"1234\"")); - response.addHeader(new BasicHeader(AUTH.WWW_AUTH, "whatever realm=\"realm1\", stuff=\"1234\"")); + response.addHeader(new BasicHeader(HttpHeaders.WWW_AUTHENTICATE, "Digest realm=\"realm1\", nonce=\"1234\"")); + response.addHeader(new BasicHeader(HttpHeaders.WWW_AUTHENTICATE, "whatever realm=\"realm1\", stuff=\"1234\"")); final DefaultAuthenticationStrategy authStrategy = new DefaultAuthenticationStrategy(); @@ -323,7 +322,7 @@ public class TestHttpAuthenticator { public void testAuthenticationException() throws Exception { final HttpHost host = new HttpHost("somehost", 80); final HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, HttpStatus.SC_UNAUTHORIZED, "UNAUTHORIZED"); - response.addHeader(new BasicHeader(AUTH.WWW_AUTH, "blah blah blah")); + response.addHeader(new BasicHeader(HttpHeaders.WWW_AUTHENTICATE, "blah blah blah")); this.authState.setState(AuthProtocolState.CHALLENGED); @@ -345,7 +344,7 @@ public class TestHttpAuthenticator { this.httpAuthenticator.generateAuthResponse(request, authState, context); - Assert.assertFalse(request.containsHeader(AUTH.WWW_AUTH_RESP)); + Assert.assertFalse(request.containsHeader(HttpHeaders.AUTHORIZATION)); Mockito.verify(this.authScheme, Mockito.never()).authenticate( Mockito.any(Credentials.class), @@ -362,11 +361,11 @@ public class TestHttpAuthenticator { Mockito.when(this.authScheme.authenticate( Mockito.any(Credentials.class), Mockito.any(HttpRequest.class), - Mockito.any(HttpContext.class))).thenReturn(new BasicHeader(AUTH.WWW_AUTH_RESP, "stuff")); + Mockito.any(HttpContext.class))).thenReturn(new BasicHeader(HttpHeaders.AUTHORIZATION, "stuff")); this.httpAuthenticator.generateAuthResponse(request, authState, context); - Assert.assertTrue(request.containsHeader(AUTH.WWW_AUTH_RESP)); + Assert.assertTrue(request.containsHeader(HttpHeaders.AUTHORIZATION)); Mockito.verify(this.authScheme).authenticate(this.credentials, request, this.context); } @@ -382,7 +381,7 @@ public class TestHttpAuthenticator { Mockito.when(this.authScheme.authenticate( Mockito.any(Credentials.class), Mockito.any(HttpRequest.class), - Mockito.any(HttpContext.class))).thenReturn(new BasicHeader(AUTH.WWW_AUTH_RESP, "stuff")); + Mockito.any(HttpContext.class))).thenReturn(new BasicHeader(HttpHeaders.AUTHORIZATION, "stuff")); this.httpAuthenticator.generateAuthResponse(request, authState, context); @@ -390,7 +389,7 @@ public class TestHttpAuthenticator { Assert.assertSame(this.credentials, this.authState.getCredentials()); Assert.assertNull(this.authState.getAuthOptions()); - Assert.assertTrue(request.containsHeader(AUTH.WWW_AUTH_RESP)); + Assert.assertTrue(request.containsHeader(HttpHeaders.AUTHORIZATION)); Mockito.verify(this.authScheme).authenticate(this.credentials, request, this.context); } @@ -410,7 +409,7 @@ public class TestHttpAuthenticator { Mockito.when(authScheme2.authenticate( Mockito.any(Credentials.class), Mockito.any(HttpRequest.class), - Mockito.any(HttpContext.class))).thenReturn(new BasicHeader(AUTH.WWW_AUTH_RESP, "stuff")); + Mockito.any(HttpContext.class))).thenReturn(new BasicHeader(HttpHeaders.AUTHORIZATION, "stuff")); authOptions.add(new AuthOption(authScheme1, this.credentials)); authOptions.add(new AuthOption(authScheme2, this.credentials)); this.authState.update(authOptions); @@ -421,7 +420,7 @@ public class TestHttpAuthenticator { Assert.assertSame(this.credentials, this.authState.getCredentials()); Assert.assertNull(this.authState.getAuthOptions()); - Assert.assertTrue(request.containsHeader(AUTH.WWW_AUTH_RESP)); + Assert.assertTrue(request.containsHeader(HttpHeaders.AUTHORIZATION)); Mockito.verify(authScheme1, Mockito.times(1)).authenticate(this.credentials, request, this.context); Mockito.verify(authScheme2, Mockito.times(1)).authenticate(this.credentials, request, this.context); @@ -437,7 +436,7 @@ public class TestHttpAuthenticator { Mockito.when(this.authScheme.authenticate( Mockito.any(Credentials.class), Mockito.any(HttpRequest.class), - Mockito.any(HttpContext.class))).thenReturn(new BasicHeader(AUTH.WWW_AUTH_RESP, "stuff")); + Mockito.any(HttpContext.class))).thenReturn(new BasicHeader(HttpHeaders.AUTHORIZATION, "stuff")); this.httpAuthenticator.generateAuthResponse(request, authState, context); @@ -445,7 +444,7 @@ public class TestHttpAuthenticator { Assert.assertSame(this.credentials, this.authState.getCredentials()); Assert.assertNull(this.authState.getAuthOptions()); - Assert.assertTrue(request.containsHeader(AUTH.WWW_AUTH_RESP)); + Assert.assertTrue(request.containsHeader(HttpHeaders.AUTHORIZATION)); Mockito.verify(this.authScheme).authenticate(this.credentials, request, this.context); } @@ -460,11 +459,11 @@ public class TestHttpAuthenticator { Mockito.when(this.authScheme.authenticate( Mockito.any(Credentials.class), Mockito.any(HttpRequest.class), - Mockito.any(HttpContext.class))).thenReturn(new BasicHeader(AUTH.WWW_AUTH_RESP, "stuff")); + Mockito.any(HttpContext.class))).thenReturn(new BasicHeader(HttpHeaders.AUTHORIZATION, "stuff")); this.httpAuthenticator.generateAuthResponse(request, authState, context); - Assert.assertFalse(request.containsHeader(AUTH.WWW_AUTH_RESP)); + Assert.assertFalse(request.containsHeader(HttpHeaders.AUTHORIZATION)); Mockito.verify(this.authScheme, Mockito.never()).authenticate( Mockito.any(Credentials.class), diff --git a/httpclient/src/test/java/org/apache/http/impl/client/TestAuthenticationStrategy.java b/httpclient/src/test/java/org/apache/http/impl/client/TestAuthenticationStrategy.java index 11af35b35..517844bdc 100644 --- a/httpclient/src/test/java/org/apache/http/impl/client/TestAuthenticationStrategy.java +++ b/httpclient/src/test/java/org/apache/http/impl/client/TestAuthenticationStrategy.java @@ -245,5 +245,5 @@ public class TestAuthenticationStrategy { final AuthOption option1 = options.remove(); Assert.assertTrue(option1.getAuthScheme() instanceof BasicScheme); } - + } diff --git a/httpclient/src/test/java/org/apache/http/impl/client/integration/TestClientAuthentication.java b/httpclient/src/test/java/org/apache/http/impl/client/integration/TestClientAuthentication.java index ff9c7597b..7663f6eac 100644 --- a/httpclient/src/test/java/org/apache/http/impl/client/integration/TestClientAuthentication.java +++ b/httpclient/src/test/java/org/apache/http/impl/client/integration/TestClientAuthentication.java @@ -35,12 +35,12 @@ import java.util.concurrent.atomic.AtomicLong; import org.apache.http.Consts; import org.apache.http.HttpEntity; import org.apache.http.HttpException; +import org.apache.http.HttpHeaders; import org.apache.http.HttpHost; import org.apache.http.HttpInetConnection; import org.apache.http.HttpRequest; import org.apache.http.HttpResponse; import org.apache.http.HttpStatus; -import org.apache.http.auth.AUTH; import org.apache.http.auth.AuthChallenge; import org.apache.http.auth.AuthOption; import org.apache.http.auth.AuthScope; @@ -424,7 +424,7 @@ public class TestClientAuthentication extends LocalServerTestBase { final String givenCreds = (String) context.getAttribute("creds"); if (givenCreds == null || !givenCreds.equals(this.realmCreds)) { response.setStatusCode(HttpStatus.SC_UNAUTHORIZED); - response.addHeader(AUTH.WWW_AUTH, "Basic realm=\"" + this.realm + "\""); + response.addHeader(HttpHeaders.WWW_AUTHENTICATE, "Basic realm=\"" + this.realm + "\""); } else { response.setStatusCode(HttpStatus.SC_OK); final StringEntity entity = new StringEntity("success", Consts.ASCII); diff --git a/httpclient/src/test/java/org/apache/http/impl/client/integration/TestClientAuthenticationFallBack.java b/httpclient/src/test/java/org/apache/http/impl/client/integration/TestClientAuthenticationFallBack.java index c04805b7b..09bcf700b 100644 --- a/httpclient/src/test/java/org/apache/http/impl/client/integration/TestClientAuthenticationFallBack.java +++ b/httpclient/src/test/java/org/apache/http/impl/client/integration/TestClientAuthenticationFallBack.java @@ -31,12 +31,12 @@ import java.io.IOException; import org.apache.http.Consts; import org.apache.http.HttpEntity; import org.apache.http.HttpException; +import org.apache.http.HttpHeaders; import org.apache.http.HttpHost; import org.apache.http.HttpRequest; import org.apache.http.HttpResponse; import org.apache.http.HttpResponseInterceptor; import org.apache.http.HttpStatus; -import org.apache.http.auth.AUTH; import org.apache.http.auth.AuthScope; import org.apache.http.auth.Credentials; import org.apache.http.auth.CredentialsProvider; @@ -68,8 +68,8 @@ public class TestClientAuthenticationFallBack extends LocalServerTestBase { final HttpResponse response, final HttpContext context) throws HttpException, IOException { if (response.getStatusLine().getStatusCode() == HttpStatus.SC_UNAUTHORIZED) { - response.addHeader(AUTH.WWW_AUTH, "Digest realm=\"test realm\" invalid"); - response.addHeader(AUTH.WWW_AUTH, "Basic realm=\"test realm\""); + response.addHeader(HttpHeaders.WWW_AUTHENTICATE, "Digest realm=\"test realm\" invalid"); + response.addHeader(HttpHeaders.WWW_AUTHENTICATE, "Basic realm=\"test realm\""); } } diff --git a/httpclient/src/test/java/org/apache/http/impl/client/integration/TestClientReauthentication.java b/httpclient/src/test/java/org/apache/http/impl/client/integration/TestClientReauthentication.java index 8481ba0c5..fd8218db0 100644 --- a/httpclient/src/test/java/org/apache/http/impl/client/integration/TestClientReauthentication.java +++ b/httpclient/src/test/java/org/apache/http/impl/client/integration/TestClientReauthentication.java @@ -33,12 +33,12 @@ import java.util.concurrent.atomic.AtomicLong; import org.apache.http.Consts; import org.apache.http.HttpEntity; import org.apache.http.HttpException; +import org.apache.http.HttpHeaders; import org.apache.http.HttpHost; import org.apache.http.HttpRequest; import org.apache.http.HttpResponse; import org.apache.http.HttpResponseInterceptor; import org.apache.http.HttpStatus; -import org.apache.http.auth.AUTH; import org.apache.http.auth.AuthScheme; import org.apache.http.auth.AuthSchemeProvider; import org.apache.http.auth.AuthScope; @@ -78,7 +78,7 @@ public class TestClientReauthentication extends LocalServerTestBase { final HttpResponse response, final HttpContext context) throws HttpException, IOException { if (response.getStatusLine().getStatusCode() == HttpStatus.SC_UNAUTHORIZED) { - response.addHeader(AUTH.WWW_AUTH, "MyBasic realm=\"test realm\""); + response.addHeader(HttpHeaders.WWW_AUTHENTICATE, "MyBasic realm=\"test realm\""); } } diff --git a/httpclient/src/test/java/org/apache/http/impl/client/integration/TestRedirects.java b/httpclient/src/test/java/org/apache/http/impl/client/integration/TestRedirects.java index 4bed0528a..22af22922 100644 --- a/httpclient/src/test/java/org/apache/http/impl/client/integration/TestRedirects.java +++ b/httpclient/src/test/java/org/apache/http/impl/client/integration/TestRedirects.java @@ -48,7 +48,6 @@ import org.apache.http.client.methods.HttpGet; import org.apache.http.client.methods.HttpPost; import org.apache.http.client.protocol.HttpClientContext; import org.apache.http.client.utils.URIUtils; -import org.apache.http.cookie.SM; import org.apache.http.entity.StringEntity; import org.apache.http.impl.client.BasicCookieStore; import org.apache.http.impl.cookie.BasicClientCookie; @@ -679,7 +678,7 @@ public class TestRedirects extends LocalServerTestBase { Assert.assertEquals(HttpStatus.SC_OK, response.getStatusLine().getStatusCode()); Assert.assertEquals("/newlocation/", reqWrapper.getRequestLine().getUri()); - final Header[] headers = reqWrapper.getHeaders(SM.COOKIE); + final Header[] headers = reqWrapper.getHeaders("Cookie"); Assert.assertEquals("There can only be one (cookie)", 1, headers.length); } diff --git a/httpclient/src/test/java/org/apache/http/localserver/BasicAuthTokenExtractor.java b/httpclient/src/test/java/org/apache/http/localserver/BasicAuthTokenExtractor.java index 3bb93c68b..8e037bd4b 100644 --- a/httpclient/src/test/java/org/apache/http/localserver/BasicAuthTokenExtractor.java +++ b/httpclient/src/test/java/org/apache/http/localserver/BasicAuthTokenExtractor.java @@ -32,9 +32,9 @@ import org.apache.commons.codec.DecoderException; import org.apache.commons.codec.binary.Base64; import org.apache.http.Header; import org.apache.http.HttpException; +import org.apache.http.HttpHeaders; import org.apache.http.HttpRequest; import org.apache.http.ProtocolException; -import org.apache.http.auth.AUTH; import org.apache.http.util.EncodingUtils; public class BasicAuthTokenExtractor { @@ -42,7 +42,7 @@ public class BasicAuthTokenExtractor { public String extract(final HttpRequest request) throws HttpException { String auth = null; - final Header h = request.getFirstHeader(AUTH.WWW_AUTH_RESP); + final Header h = request.getFirstHeader(HttpHeaders.AUTHORIZATION); if (h != null) { final String s = h.getValue(); if (s != null) { diff --git a/httpclient/src/test/java/org/apache/http/localserver/ResponseBasicUnauthorized.java b/httpclient/src/test/java/org/apache/http/localserver/ResponseBasicUnauthorized.java index a6a92b503..d4f1210c6 100644 --- a/httpclient/src/test/java/org/apache/http/localserver/ResponseBasicUnauthorized.java +++ b/httpclient/src/test/java/org/apache/http/localserver/ResponseBasicUnauthorized.java @@ -30,10 +30,10 @@ package org.apache.http.localserver; import java.io.IOException; import org.apache.http.HttpException; +import org.apache.http.HttpHeaders; import org.apache.http.HttpResponse; import org.apache.http.HttpResponseInterceptor; import org.apache.http.HttpStatus; -import org.apache.http.auth.AUTH; import org.apache.http.protocol.HttpContext; public class ResponseBasicUnauthorized implements HttpResponseInterceptor { @@ -43,8 +43,8 @@ public class ResponseBasicUnauthorized implements HttpResponseInterceptor { final HttpResponse response, final HttpContext context) throws HttpException, IOException { if (response.getStatusLine().getStatusCode() == HttpStatus.SC_UNAUTHORIZED) { - if (!response.containsHeader(AUTH.WWW_AUTH)) { - response.addHeader(AUTH.WWW_AUTH, "Basic realm=\"test realm\""); + if (!response.containsHeader(HttpHeaders.WWW_AUTHENTICATE)) { + response.addHeader(HttpHeaders.WWW_AUTHENTICATE, "Basic realm=\"test realm\""); } } }