You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-commits@axis.apache.org by ro...@apache.org on 2026/01/29 01:40:46 UTC
(axis-axis2-c-core) branch master updated (67e4baecd -> 3f0f3f9f2)
This is an automated email from the ASF dual-hosted git repository.
robertlazarski pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/axis-axis2-c-core.git
from 67e4baecd Fix SSL stream read treating end-of-stream as error (AXIS2C-1618)
new b8acb5c79 Fix client incorrectly deleting cookies when Set-Cookie absent (AXIS2C-1566)
new 3f0f3f9f2 Add unit test for cookie persistence fix (AXIS2C-1566)
The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
src/core/transport/http/sender/http_sender.c | 9 +-
test/core/transport/http/Makefile.am | 34 ++++-
test/core/transport/http/test_axis2c_1566.cc | 213 +++++++++++++++++++++++++++
3 files changed, 247 insertions(+), 9 deletions(-)
create mode 100644 test/core/transport/http/test_axis2c_1566.cc
(axis-axis2-c-core) 02/02: Add unit test for cookie persistence fix (AXIS2C-1566)
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
robertlazarski pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/axis-axis2-c-core.git
commit 3f0f3f9f270277a6d8f26ea0c959600e857e2a09
Author: Robert Lazarski <ro...@gmail.com>
AuthorDate: Wed Jan 28 15:39:09 2026 -1000
Add unit test for cookie persistence fix (AXIS2C-1566)
Test verifies that HTTP cookies are NOT deleted when the server response
does not include a Set-Cookie header. Per RFC 6265, cookies should persist
until they expire or the server explicitly deletes them.
Two test cases:
- CookiePersistsWithoutSetCookieHeader: Verifies the fix
- NewCookieIsStoredFromSetCookieHeader: Regression test for normal behavior
Co-Authored-By: Claude Opus 4.5 <no...@anthropic.com>
---
test/core/transport/http/Makefile.am | 34 ++++-
test/core/transport/http/test_axis2c_1566.cc | 213 +++++++++++++++++++++++++++
2 files changed, 244 insertions(+), 3 deletions(-)
diff --git a/test/core/transport/http/Makefile.am b/test/core/transport/http/Makefile.am
index 405b4a0d3..feab6be6d 100644
--- a/test/core/transport/http/Makefile.am
+++ b/test/core/transport/http/Makefile.am
@@ -27,9 +27,9 @@ TESTS =
# HTTP/2 mode doesn't build the receiver/sender libraries that this test needs
if GTEST_AVAILABLE
if !WITH_NGHTTP2
-check_PROGRAMS += test_http_transport test_axis2c_1480 test_axis2c_1532
-noinst_PROGRAMS += test_http_transport test_axis2c_1480 test_axis2c_1532
-TESTS += test_http_transport test_axis2c_1480 test_axis2c_1532
+check_PROGRAMS += test_http_transport test_axis2c_1480 test_axis2c_1532 test_axis2c_1566
+noinst_PROGRAMS += test_http_transport test_axis2c_1480 test_axis2c_1532 test_axis2c_1566
+TESTS += test_http_transport test_axis2c_1480 test_axis2c_1532 test_axis2c_1566
# ASAN preload for libtool-wrapped test execution
if ENABLE_ASAN
@@ -112,12 +112,40 @@ test_axis2c_1532_CPPFLAGS = \
-I ../../../../axiom/include \
-I $(GTEST_DIR)/include
+# AXIS2C-1566: Cookie persistence tests
+test_axis2c_1566_SOURCES = test_axis2c_1566.cc
+
+test_axis2c_1566_LDADD = \
+ $(LDFLAGS) \
+ ../../../../util/src/libaxutil.la \
+ ../../../../axiom/src/om/libaxis2_axiom.la \
+ $(top_builddir)/neethi/src/libneethi.la \
+ ../../../../axiom/src/parser/$(WRAPPER_DIR)/libaxis2_parser.la \
+ $(top_builddir)/src/core/engine/libaxis2_engine.la \
+ $(top_builddir)/src/core/transport/http/receiver/libaxis2_http_receiver.la \
+ $(top_builddir)/src/core/transport/http/sender/libaxis2_http_sender.la \
+ $(top_builddir)/src/core/transport/http/common/libaxis2_http_common.la \
+ $(top_builddir)/src/core/transport/http/util/libaxis2_http_util.la \
+ $(top_builddir)/$(GTEST)/libgtest.a \
+ $(top_builddir)/$(GTEST)/libgtest_main.a \
+ -lpthread
+
+test_axis2c_1566_LDFLAGS = -Wl,--no-as-needed
+
+test_axis2c_1566_CPPFLAGS = \
+ -I$(top_builddir)/include \
+ -I ../../../../util/include \
+ -I ../../../../axiom/include \
+ -I $(GTEST_DIR)/include
+
# Add JSON support conditionally
if AXIS2_JSON_ENABLED
test_http_transport_LDADD += $(JSON_LIBS)
test_http_transport_CPPFLAGS += $(JSON_CFLAGS)
test_axis2c_1480_LDADD += $(JSON_LIBS)
test_axis2c_1480_CPPFLAGS += $(JSON_CFLAGS)
+test_axis2c_1566_LDADD += $(JSON_LIBS)
+test_axis2c_1566_CPPFLAGS += $(JSON_CFLAGS)
endif
endif
endif
diff --git a/test/core/transport/http/test_axis2c_1566.cc b/test/core/transport/http/test_axis2c_1566.cc
new file mode 100644
index 000000000..00adadd87
--- /dev/null
+++ b/test/core/transport/http/test_axis2c_1566.cc
@@ -0,0 +1,213 @@
+/*
+ * 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.
+ */
+
+/**
+ * @file test_axis2c_1566.cc
+ * @brief Unit test for AXIS2C-1566: Cookie persistence when Set-Cookie absent
+ *
+ * This test verifies that HTTP cookies are NOT deleted when the server
+ * response does not include a Set-Cookie header. Per RFC 6265, cookies
+ * should persist until they expire or the server explicitly deletes them.
+ *
+ * Prior to the fix, the client would delete all cookies if the server
+ * response didn't include a Set-Cookie header, breaking session management.
+ */
+
+#include <gtest/gtest.h>
+
+extern "C" {
+#include <axutil_env.h>
+#include <axutil_allocator.h>
+#include <axutil_error_default.h>
+#include <axutil_log_default.h>
+#include <axutil_property.h>
+#include <axutil_hash.h>
+#include <axis2_msg_ctx.h>
+#include <axis2_conf_ctx.h>
+#include <axis2_conf.h>
+#include <axis2_endpoint_ref.h>
+#include <axis2_http_sender.h>
+#include <axis2_http_simple_response.h>
+#include <axis2_http_transport.h>
+#include <axis2_http_transport_utils.h>
+#include <axis2_http_header.h>
+}
+
+#define TEST_ENDPOINT "http://example.com/service"
+#define TEST_COOKIE "SESSIONID=abc123; Path=/"
+
+class CookiePersistenceTest : public ::testing::Test {
+protected:
+ axutil_env_t *env;
+ axutil_allocator_t *allocator;
+ axutil_error_t *error;
+ axutil_log_t *log;
+ axis2_conf_ctx_t *conf_ctx;
+ axis2_conf_t *conf;
+
+ void SetUp() override {
+ allocator = axutil_allocator_init(NULL);
+ ASSERT_NE(allocator, nullptr) << "Failed to create allocator";
+
+ error = axutil_error_create(allocator);
+ log = axutil_log_create(allocator, NULL, NULL);
+ env = axutil_env_create_with_error_log(allocator, error, log);
+ ASSERT_NE(env, nullptr) << "Failed to create environment";
+
+ conf = axis2_conf_create(env);
+ ASSERT_NE(conf, nullptr) << "Failed to create configuration";
+
+ conf_ctx = axis2_conf_ctx_create(env, conf);
+ ASSERT_NE(conf_ctx, nullptr) << "Failed to create configuration context";
+ }
+
+ void TearDown() override {
+ if (conf_ctx) {
+ axis2_conf_ctx_free(conf_ctx, env);
+ }
+ if (env) {
+ axutil_env_free(env);
+ }
+ }
+};
+
+/**
+ * Test that cookies persist when server response has no Set-Cookie header.
+ *
+ * This is the main test for AXIS2C-1566. The bug was that the HTTP client
+ * would delete stored cookies if the server response didn't include a
+ * Set-Cookie header, which is incorrect per RFC 6265.
+ */
+TEST_F(CookiePersistenceTest, CookiePersistsWithoutSetCookieHeader) {
+ axis2_msg_ctx_t *msg_ctx = NULL;
+ axis2_endpoint_ref_t *endpoint_ref = NULL;
+ axis2_http_sender_t *sender = NULL;
+ axis2_http_simple_response_t *response = NULL;
+ axis2_char_t *cookie_before = NULL;
+ axis2_char_t *cookie_after = NULL;
+
+ /* Create message context */
+ msg_ctx = axis2_msg_ctx_create(env, conf_ctx, NULL, NULL);
+ ASSERT_NE(msg_ctx, nullptr) << "Failed to create message context";
+
+ /* Set endpoint reference - needed for cookie storage keying */
+ endpoint_ref = axis2_endpoint_ref_create(env, TEST_ENDPOINT);
+ ASSERT_NE(endpoint_ref, nullptr) << "Failed to create endpoint reference";
+ axis2_msg_ctx_set_to(msg_ctx, env, endpoint_ref);
+
+ /* Store a cookie for this endpoint */
+ axis2_http_transport_utils_store_cookie(env, msg_ctx, (axis2_char_t*)TEST_COOKIE);
+
+ /* Verify cookie was stored */
+ cookie_before = axis2_http_transport_utils_read_from_cookie_store(env, msg_ctx);
+ ASSERT_NE(cookie_before, nullptr) << "Cookie was not stored initially";
+ EXPECT_STREQ(cookie_before, TEST_COOKIE) << "Stored cookie doesn't match";
+
+ /* Create HTTP response WITHOUT Set-Cookie header */
+ response = axis2_http_simple_response_create_default(env);
+ ASSERT_NE(response, nullptr) << "Failed to create HTTP response";
+
+ /* Set a basic response status (200 OK) */
+ axis2_http_simple_response_set_status_line(response, env,
+ (axis2_char_t*)"HTTP/1.1", 200, (axis2_char_t*)"OK");
+
+ /* Add some headers but NOT Set-Cookie */
+ axis2_http_simple_response_set_header(response, env,
+ axis2_http_header_create(env, (axis2_char_t*)"Content-Type",
+ (axis2_char_t*)"text/xml"));
+ axis2_http_simple_response_set_header(response, env,
+ axis2_http_header_create(env, (axis2_char_t*)"Content-Length",
+ (axis2_char_t*)"100"));
+
+ /* Create HTTP sender */
+ sender = axis2_http_sender_create(env);
+ ASSERT_NE(sender, nullptr) << "Failed to create HTTP sender";
+
+ /* Process the response headers - this is where the bug manifested */
+ axis2_http_sender_get_header_info(sender, env, msg_ctx, response);
+
+ /* Read cookie after processing - should still be there! */
+ cookie_after = axis2_http_transport_utils_read_from_cookie_store(env, msg_ctx);
+
+ /* THE CRITICAL ASSERTION: Cookie must persist */
+ ASSERT_NE(cookie_after, nullptr)
+ << "AXIS2C-1566: Cookie was incorrectly deleted when Set-Cookie header was absent. "
+ << "Per RFC 6265, cookies should persist until they expire or are explicitly deleted.";
+
+ EXPECT_STREQ(cookie_after, TEST_COOKIE)
+ << "Cookie value changed unexpectedly";
+
+ /* Cleanup */
+ if (sender) axis2_http_sender_free(sender, env);
+ if (response) axis2_http_simple_response_free(response, env);
+ if (msg_ctx) axis2_msg_ctx_free(msg_ctx, env);
+}
+
+/**
+ * Test that new cookies from Set-Cookie header are still properly stored.
+ *
+ * This verifies we didn't break the normal cookie setting behavior while
+ * fixing the deletion bug.
+ */
+TEST_F(CookiePersistenceTest, NewCookieIsStoredFromSetCookieHeader) {
+ axis2_msg_ctx_t *msg_ctx = NULL;
+ axis2_endpoint_ref_t *endpoint_ref = NULL;
+ axis2_http_sender_t *sender = NULL;
+ axis2_http_simple_response_t *response = NULL;
+ axis2_char_t *cookie_after = NULL;
+ const char *NEW_COOKIE = "NEWSESSION=xyz789; Path=/";
+
+ /* Create message context */
+ msg_ctx = axis2_msg_ctx_create(env, conf_ctx, NULL, NULL);
+ ASSERT_NE(msg_ctx, nullptr);
+
+ /* Set endpoint reference */
+ endpoint_ref = axis2_endpoint_ref_create(env, TEST_ENDPOINT);
+ ASSERT_NE(endpoint_ref, nullptr);
+ axis2_msg_ctx_set_to(msg_ctx, env, endpoint_ref);
+
+ /* Create HTTP response WITH Set-Cookie header */
+ response = axis2_http_simple_response_create_default(env);
+ ASSERT_NE(response, nullptr);
+
+ axis2_http_simple_response_set_status_line(response, env,
+ (axis2_char_t*)"HTTP/1.1", 200, (axis2_char_t*)"OK");
+
+ /* Add Set-Cookie header */
+ axis2_http_simple_response_set_header(response, env,
+ axis2_http_header_create(env, (axis2_char_t*)"Set-Cookie",
+ (axis2_char_t*)NEW_COOKIE));
+
+ /* Create HTTP sender and process headers */
+ sender = axis2_http_sender_create(env);
+ ASSERT_NE(sender, nullptr);
+
+ axis2_http_sender_get_header_info(sender, env, msg_ctx, response);
+
+ /* Verify new cookie was stored */
+ cookie_after = axis2_http_transport_utils_read_from_cookie_store(env, msg_ctx);
+ ASSERT_NE(cookie_after, nullptr)
+ << "New cookie from Set-Cookie header was not stored";
+
+ EXPECT_STREQ(cookie_after, NEW_COOKIE)
+ << "Stored cookie doesn't match Set-Cookie header value";
+
+ /* Cleanup */
+ if (sender) axis2_http_sender_free(sender, env);
+ if (response) axis2_http_simple_response_free(response, env);
+ if (msg_ctx) axis2_msg_ctx_free(msg_ctx, env);
+}
(axis-axis2-c-core) 01/02: Fix client incorrectly deleting cookies when Set-Cookie absent (AXIS2C-1566)
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
robertlazarski pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/axis-axis2-c-core.git
commit b8acb5c79e165950d93f3b489857cc9e29419ed2
Author: Robert Lazarski <ro...@gmail.com>
AuthorDate: Wed Jan 28 15:34:46 2026 -1000
Fix client incorrectly deleting cookies when Set-Cookie absent (AXIS2C-1566)
The HTTP client was incorrectly removing cookies when the server response
did not include a Set-Cookie header. Per RFC 6265, cookies should persist
until they expire or the server explicitly deletes them with Max-Age=0.
The absence of Set-Cookie does NOT mean cookies should be deleted. This
caused session cookies to be lost after the first successful request.
Co-Authored-By: Claude Opus 4.5 <no...@anthropic.com>
---
src/core/transport/http/sender/http_sender.c | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)
diff --git a/src/core/transport/http/sender/http_sender.c b/src/core/transport/http/sender/http_sender.c
index 9cdd47203..6aad128e6 100644
--- a/src/core/transport/http/sender/http_sender.c
+++ b/src/core/transport/http/sender/http_sender.c
@@ -1554,7 +1554,6 @@ axis2_http_sender_get_header_info(
axutil_property_t *property = NULL;
axis2_char_t *content_type = NULL;
/*int status_code = 0;*/
- axis2_bool_t set_cookie_header_present = AXIS2_FALSE;
axis2_bool_t connection_header_present = AXIS2_FALSE;
AXIS2_PARAM_CHECK(env->error, msg_ctx, AXIS2_FAILURE);
@@ -1601,7 +1600,6 @@ axis2_http_sender_get_header_info(
{
axis2_http_transport_utils_store_cookie(env, msg_ctx, cookie_str);
}
- set_cookie_header_present = AXIS2_TRUE;
}
if(!axutil_strcasecmp(name, AXIS2_HTTP_HEADER_CONNECTION))
@@ -1642,10 +1640,9 @@ axis2_http_sender_get_header_info(
} /* End if name is connection */
} /* End if name of the header present */
}
- if(!set_cookie_header_present) /* We need to remove any cookie set previously for this endpoint */
- {
- axis2_http_transport_utils_store_cookie(env, msg_ctx, NULL);
- }
+ /* Note: Cookies should NOT be removed when Set-Cookie header is absent.
+ * Per RFC 6265, cookies persist until they expire or the server explicitly
+ * deletes them with Set-Cookie: name=; Max-Age=0 (AXIS2C-1566) */
if(!connection_header_present) /* No connection header present */
{
/** In HTTP1.0 if there is no keep alive header sent back from server we drop the