Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 46E9C200C13 for ; Mon, 6 Feb 2017 15:16:51 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 458C5160B53; Mon, 6 Feb 2017 14:16:51 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 8D3DE160B49 for ; Mon, 6 Feb 2017 15:16:50 +0100 (CET) Received: (qmail 26104 invoked by uid 500); 6 Feb 2017 14:16:49 -0000 Mailing-List: contact commits-help@activemq.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@activemq.apache.org Delivered-To: mailing list commits@activemq.apache.org Received: (qmail 26095 invoked by uid 99); 6 Feb 2017 14:16:49 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 06 Feb 2017 14:16:49 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 7D501DFCA3; Mon, 6 Feb 2017 14:16:49 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: cshannon@apache.org To: commits@activemq.apache.org Message-Id: <4f43c2285b584cc2b9b859bf3ea350b1@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: activemq git commit: [AMQ-6571] use browsercompatspec cookie matcher - apply patch from Andrew Flegg with thanks Date: Mon, 6 Feb 2017 14:16:49 +0000 (UTC) archived-at: Mon, 06 Feb 2017 14:16:51 -0000 Repository: activemq Updated Branches: refs/heads/activemq-5.14.x 8af72c215 -> c5315d6d5 [AMQ-6571] use browsercompatspec cookie matcher - apply patch from Andrew Flegg with thanks (cherry picked from commit 4f6c55ad67f8e080d5bc3adba124f5e76d9f0224) Project: http://git-wip-us.apache.org/repos/asf/activemq/repo Commit: http://git-wip-us.apache.org/repos/asf/activemq/commit/c5315d6d Tree: http://git-wip-us.apache.org/repos/asf/activemq/tree/c5315d6d Diff: http://git-wip-us.apache.org/repos/asf/activemq/diff/c5315d6d Branch: refs/heads/activemq-5.14.x Commit: c5315d6d5ea45ec78bfdc268819904de559483c8 Parents: 8af72c2 Author: gtully Authored: Fri Jan 20 14:54:37 2017 +0000 Committer: Christopher L. Shannon (cshannon) Committed: Mon Feb 6 09:13:15 2017 -0500 ---------------------------------------------------------------------- .../transport/http/HttpClientTransport.java | 3 + .../HttpClientTransportCookiePolicyTest.java | 61 ++++++++++++++++++++ 2 files changed, 64 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/activemq/blob/c5315d6d/activemq-http/src/main/java/org/apache/activemq/transport/http/HttpClientTransport.java ---------------------------------------------------------------------- diff --git a/activemq-http/src/main/java/org/apache/activemq/transport/http/HttpClientTransport.java b/activemq-http/src/main/java/org/apache/activemq/transport/http/HttpClientTransport.java index a06e7fd..153e5d6 100755 --- a/activemq-http/src/main/java/org/apache/activemq/transport/http/HttpClientTransport.java +++ b/activemq-http/src/main/java/org/apache/activemq/transport/http/HttpClientTransport.java @@ -47,6 +47,8 @@ import org.apache.http.client.methods.HttpGet; import org.apache.http.client.methods.HttpHead; import org.apache.http.client.methods.HttpOptions; import org.apache.http.client.methods.HttpPost; +import org.apache.http.client.params.CookiePolicy; +import org.apache.http.client.params.HttpClientParams; import org.apache.http.conn.ClientConnectionManager; import org.apache.http.conn.params.ConnRoutePNames; import org.apache.http.conn.scheme.PlainSocketFactory; @@ -342,6 +344,7 @@ public class HttpClientTransport extends HttpTransportSupport { HttpParams params = client.getParams(); HttpConnectionParams.setSoTimeout(params, soTimeout); + HttpClientParams.setCookiePolicy(params, CookiePolicy.BROWSER_COMPATIBILITY); return client; } http://git-wip-us.apache.org/repos/asf/activemq/blob/c5315d6d/activemq-http/src/test/java/org/apache/activemq/transport/http/HttpClientTransportCookiePolicyTest.java ---------------------------------------------------------------------- diff --git a/activemq-http/src/test/java/org/apache/activemq/transport/http/HttpClientTransportCookiePolicyTest.java b/activemq-http/src/test/java/org/apache/activemq/transport/http/HttpClientTransportCookiePolicyTest.java new file mode 100644 index 0000000..b0f5691 --- /dev/null +++ b/activemq-http/src/test/java/org/apache/activemq/transport/http/HttpClientTransportCookiePolicyTest.java @@ -0,0 +1,61 @@ +/** + * 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. + */ +package org.apache.activemq.transport.http; + +import static org.junit.Assert.assertEquals; +import static org.mockito.Mockito.mock; + +import java.net.URI; +import java.net.URISyntaxException; + +import org.apache.activemq.transport.util.TextWireFormat; +import org.apache.http.client.HttpClient; +import org.apache.http.client.params.HttpClientParams; +import org.junit.Before; +import org.junit.Test; + +/** + * Test that {@link HttpClientTransport} sets a broad-range compatibility + * cookie policy. + * + * @see AMQ-6571: HttpClientTransport refuses to accept cookies using `Expires' header + */ +@SuppressWarnings("deprecation") +public class HttpClientTransportCookiePolicyTest { + + private HttpClientTransport transport; + + + /** + * Create the transport so we can inspect it. + * @throws URISyntaxException if something goes wrong. + */ + @Before + public void setUp() throws URISyntaxException { + transport = new HttpClientTransport(mock(TextWireFormat.class), new URI("http://localhost:8080/test")); + } + + + /** + * Create a new connection and check the connection properties. + */ + @Test + public void test() { + HttpClient client = transport.createHttpClient(); + assertEquals("Cookie spec", org.apache.http.client.params.CookiePolicy.BROWSER_COMPATIBILITY, HttpClientParams.getCookiePolicy(client.getParams())); + } +}