Skip to content

Commit

Permalink
Merge pull request #2175 from ballerina-platform/fix-add-header-5.x
Browse files Browse the repository at this point in the history
[2201.5.x] Fix `Content-Type` header duplication via `addHeader` method
  • Loading branch information
TharmiganK authored Oct 16, 2024
2 parents 8637581 + 29a14a0 commit 915c96e
Show file tree
Hide file tree
Showing 34 changed files with 121 additions and 81 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/central-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
- name: Create lib directory if not exists
run: mkdir -p ballerina/lib
- name: Run Trivy vulnerability scanner
uses: aquasecurity/trivy-action@master
uses: aquasecurity/trivy-action@0.23.0
with:
scan-type: 'rootfs'
scan-ref: '/github/workspace/ballerina/lib'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
- name: Create lib directory if not exists
run: mkdir -p ballerina/lib
- name: Run Trivy vulnerability scanner
uses: aquasecurity/trivy-action@master
uses: aquasecurity/trivy-action@0.23.0
with:
scan-type: 'rootfs'
scan-ref: '/github/workspace/ballerina/lib'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/trivy-scan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
- name: Create lib directory if not exists
run: mkdir -p ballerina/lib
- name: Run Trivy vulnerability scanner
uses: aquasecurity/trivy-action@master
uses: aquasecurity/trivy-action@0.23.0
with:
scan-type: 'rootfs'
scan-ref: '/github/workspace/ballerina/lib'
Expand Down
1 change: 1 addition & 0 deletions .trivyignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ CVE-2024-34447
CVE-2024-29857
CVE-2024-30171
CVE-2024-30172
CVE-2024-7254
2 changes: 1 addition & 1 deletion ballerina-tests/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ task startLdapServer() {
if (!stdOut.toString().contains("openldap-server")) {
println "Starting LDAP server."
exec {
commandLine 'sh', '-c', "docker-compose -f $project.projectDir/resources/openldap/docker-compose.yml up -d"
commandLine 'sh', '-c', "docker compose -f $project.projectDir/resources/openldap/compose.yml up -d"
standardOutput = stdOut
}
println stdOut.toString()
Expand Down
6 changes: 3 additions & 3 deletions ballerina-tests/http-advanced-tests/Ballerina.toml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
[package]
org = "ballerina"
name = "http_advanced_tests"
version = "2.7.7"
version = "2.7.8"

[[dependency]]
org = "ballerina"
name = "http_test_common"
repository = "local"
version = "2.7.7"
version = "2.7.8"

[[platform.java11.dependency]]
scope = "testOnly"
path = "../../test-utils/build/libs/http-test-utils-2.7.7.jar"
path = "../../test-utils/build/libs/http-test-utils-2.7.8-SNAPSHOT.jar"
6 changes: 3 additions & 3 deletions ballerina-tests/http-advanced-tests/Dependencies.toml
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ modules = [
[[package]]
org = "ballerina"
name = "http"
version = "2.7.7"
version = "2.7.8"
scope = "testOnly"
dependencies = [
{org = "ballerina", name = "auth"},
Expand Down Expand Up @@ -105,7 +105,7 @@ modules = [
[[package]]
org = "ballerina"
name = "http_advanced_tests"
version = "2.7.7"
version = "2.7.8"
dependencies = [
{org = "ballerina", name = "crypto"},
{org = "ballerina", name = "file"},
Expand All @@ -125,7 +125,7 @@ modules = [
[[package]]
org = "ballerina"
name = "http_test_common"
version = "2.7.7"
version = "2.7.8"
scope = "testOnly"
dependencies = [
{org = "ballerina", name = "lang.string"},
Expand Down
6 changes: 3 additions & 3 deletions ballerina-tests/http-client-tests/Ballerina.toml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
[package]
org = "ballerina"
name = "http_client_tests"
version = "2.7.7"
version = "2.7.8"

[[dependency]]
org = "ballerina"
name = "http_test_common"
repository = "local"
version = "2.7.7"
version = "2.7.8"

[[platform.java11.dependency]]
scope = "testOnly"
path = "../../test-utils/build/libs/http-test-utils-2.7.7.jar"
path = "../../test-utils/build/libs/http-test-utils-2.7.8-SNAPSHOT.jar"
6 changes: 3 additions & 3 deletions ballerina-tests/http-client-tests/Dependencies.toml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ dependencies = [
[[package]]
org = "ballerina"
name = "http"
version = "2.7.7"
version = "2.7.8"
scope = "testOnly"
dependencies = [
{org = "ballerina", name = "auth"},
Expand Down Expand Up @@ -102,7 +102,7 @@ modules = [
[[package]]
org = "ballerina"
name = "http_client_tests"
version = "2.7.7"
version = "2.7.8"
dependencies = [
{org = "ballerina", name = "constraint"},
{org = "ballerina", name = "http"},
Expand All @@ -121,7 +121,7 @@ modules = [
[[package]]
org = "ballerina"
name = "http_test_common"
version = "2.7.7"
version = "2.7.8"
scope = "testOnly"
dependencies = [
{org = "ballerina", name = "lang.string"},
Expand Down
6 changes: 3 additions & 3 deletions ballerina-tests/http-dispatching-tests/Ballerina.toml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
[package]
org = "ballerina"
name = "http_dispatching_tests"
version = "2.7.7"
version = "2.7.8"

[[dependency]]
org = "ballerina"
name = "http_test_common"
repository = "local"
version = "2.7.7"
version = "2.7.8"

[[platform.java11.dependency]]
scope = "testOnly"
path = "../../test-utils/build/libs/http-test-utils-2.7.7.jar"
path = "../../test-utils/build/libs/http-test-utils-2.7.8-SNAPSHOT.jar"
6 changes: 3 additions & 3 deletions ballerina-tests/http-dispatching-tests/Dependencies.toml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ dependencies = [
[[package]]
org = "ballerina"
name = "http"
version = "2.7.7"
version = "2.7.8"
scope = "testOnly"
dependencies = [
{org = "ballerina", name = "auth"},
Expand Down Expand Up @@ -99,7 +99,7 @@ modules = [
[[package]]
org = "ballerina"
name = "http_dispatching_tests"
version = "2.7.7"
version = "2.7.8"
dependencies = [
{org = "ballerina", name = "http"},
{org = "ballerina", name = "http_test_common"},
Expand All @@ -120,7 +120,7 @@ modules = [
[[package]]
org = "ballerina"
name = "http_test_common"
version = "2.7.7"
version = "2.7.8"
scope = "testOnly"
dependencies = [
{org = "ballerina", name = "lang.string"},
Expand Down
6 changes: 3 additions & 3 deletions ballerina-tests/http-interceptor-tests/Ballerina.toml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
[package]
org = "ballerina"
name = "http_interceptor_tests"
version = "2.7.7"
version = "2.7.8"

[[dependency]]
org = "ballerina"
name = "http_test_common"
repository = "local"
version = "2.7.7"
version = "2.7.8"

[[platform.java11.dependency]]
scope = "testOnly"
path = "../../test-utils/build/libs/http-test-utils-2.7.7.jar"
path = "../../test-utils/build/libs/http-test-utils-2.7.8-SNAPSHOT.jar"
6 changes: 3 additions & 3 deletions ballerina-tests/http-interceptor-tests/Dependencies.toml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ dependencies = [
[[package]]
org = "ballerina"
name = "http"
version = "2.7.7"
version = "2.7.8"
scope = "testOnly"
dependencies = [
{org = "ballerina", name = "auth"},
Expand Down Expand Up @@ -99,7 +99,7 @@ modules = [
[[package]]
org = "ballerina"
name = "http_interceptor_tests"
version = "2.7.7"
version = "2.7.8"
dependencies = [
{org = "ballerina", name = "http"},
{org = "ballerina", name = "http_test_common"},
Expand All @@ -115,7 +115,7 @@ modules = [
[[package]]
org = "ballerina"
name = "http_test_common"
version = "2.7.7"
version = "2.7.8"
scope = "testOnly"
dependencies = [
{org = "ballerina", name = "lang.string"},
Expand Down
6 changes: 3 additions & 3 deletions ballerina-tests/http-misc-tests/Ballerina.toml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
[package]
org = "ballerina"
name = "http_misc_tests"
version = "2.7.7"
version = "2.7.8"

[[dependency]]
org = "ballerina"
name = "http_test_common"
repository = "local"
version = "2.7.7"
version = "2.7.8"

[[platform.java11.dependency]]
scope = "testOnly"
path = "../../test-utils/build/libs/http-test-utils-2.7.7.jar"
path = "../../test-utils/build/libs/http-test-utils-2.7.8-SNAPSHOT.jar"
6 changes: 3 additions & 3 deletions ballerina-tests/http-misc-tests/Dependencies.toml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ dependencies = [
[[package]]
org = "ballerina"
name = "http"
version = "2.7.7"
version = "2.7.8"
scope = "testOnly"
dependencies = [
{org = "ballerina", name = "auth"},
Expand Down Expand Up @@ -99,7 +99,7 @@ modules = [
[[package]]
org = "ballerina"
name = "http_misc_tests"
version = "2.7.7"
version = "2.7.8"
dependencies = [
{org = "ballerina", name = "http"},
{org = "ballerina", name = "http_test_common"},
Expand All @@ -118,7 +118,7 @@ modules = [
[[package]]
org = "ballerina"
name = "http_test_common"
version = "2.7.7"
version = "2.7.8"
scope = "testOnly"
dependencies = [
{org = "ballerina", name = "lang.string"},
Expand Down
22 changes: 22 additions & 0 deletions ballerina-tests/http-misc-tests/tests/http_header_test.bal
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
// specific language governing permissions and limitations
// under the License.

import ballerina/mime;
import ballerina/test;
import ballerina/http;
import ballerina/http_test_common as common;
Expand Down Expand Up @@ -276,3 +277,24 @@ function testPassthruWithBody() returns error? {
}
}

@test:Config {}
function testAddHeaderWithContentType() returns error? {
http:Request req = new;
check req.setContentType(mime:APPLICATION_JSON);
test:assertEquals(check req.getHeaders(http:CONTENT_TYPE), [mime:APPLICATION_JSON]);
req.addHeader(http:CONTENT_TYPE, mime:APPLICATION_XML);
test:assertEquals(check req.getHeaders(http:CONTENT_TYPE), [mime:APPLICATION_XML]);

http:Response res = new;
check res.setContentType(mime:APPLICATION_JSON);
test:assertEquals(check res.getHeaders(http:CONTENT_TYPE), [mime:APPLICATION_JSON]);
res.addHeader(http:CONTENT_TYPE, mime:APPLICATION_XML);
test:assertEquals(check res.getHeaders(http:CONTENT_TYPE), [mime:APPLICATION_XML]);

http:PushPromise pushPromise = new;
pushPromise.addHeader(http:CONTENT_TYPE, mime:APPLICATION_JSON);
test:assertEquals(pushPromise.getHeaders(http:CONTENT_TYPE), [mime:APPLICATION_JSON]);
pushPromise.addHeader(http:CONTENT_TYPE, mime:APPLICATION_XML);
test:assertEquals(pushPromise.getHeaders(http:CONTENT_TYPE), [mime:APPLICATION_XML]);
}

6 changes: 3 additions & 3 deletions ballerina-tests/http-resiliency-tests/Ballerina.toml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
[package]
org = "ballerina"
name = "http_resiliency_tests"
version = "2.7.7"
version = "2.7.8"

[[dependency]]
org = "ballerina"
name = "http_test_common"
repository = "local"
version = "2.7.7"
version = "2.7.8"

[[platform.java11.dependency]]
scope = "testOnly"
path = "../../test-utils/build/libs/http-test-utils-2.7.7.jar"
path = "../../test-utils/build/libs/http-test-utils-2.7.8-SNAPSHOT.jar"
6 changes: 3 additions & 3 deletions ballerina-tests/http-resiliency-tests/Dependencies.toml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ dependencies = [
[[package]]
org = "ballerina"
name = "http"
version = "2.7.7"
version = "2.7.8"
scope = "testOnly"
dependencies = [
{org = "ballerina", name = "auth"},
Expand Down Expand Up @@ -99,7 +99,7 @@ modules = [
[[package]]
org = "ballerina"
name = "http_resiliency_tests"
version = "2.7.7"
version = "2.7.8"
dependencies = [
{org = "ballerina", name = "http"},
{org = "ballerina", name = "http_test_common"},
Expand All @@ -116,7 +116,7 @@ modules = [
[[package]]
org = "ballerina"
name = "http_test_common"
version = "2.7.7"
version = "2.7.8"
scope = "testOnly"
dependencies = [
{org = "ballerina", name = "lang.string"},
Expand Down
6 changes: 3 additions & 3 deletions ballerina-tests/http-security-tests/Ballerina.toml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
[package]
org = "ballerina"
name = "http_security_tests"
version = "2.7.7"
version = "2.7.8"

[[dependency]]
org = "ballerina"
name = "http_test_common"
repository = "local"
version = "2.7.7"
version = "2.7.8"

[[platform.java11.dependency]]
scope = "testOnly"
path = "../../test-utils/build/libs/http-test-utils-2.7.7.jar"
path = "../../test-utils/build/libs/http-test-utils-2.7.8-SNAPSHOT.jar"
6 changes: 3 additions & 3 deletions ballerina-tests/http-security-tests/Dependencies.toml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ dependencies = [
[[package]]
org = "ballerina"
name = "http"
version = "2.7.7"
version = "2.7.8"
scope = "testOnly"
dependencies = [
{org = "ballerina", name = "auth"},
Expand Down Expand Up @@ -102,7 +102,7 @@ modules = [
[[package]]
org = "ballerina"
name = "http_security_tests"
version = "2.7.7"
version = "2.7.8"
dependencies = [
{org = "ballerina", name = "auth"},
{org = "ballerina", name = "http"},
Expand All @@ -121,7 +121,7 @@ modules = [
[[package]]
org = "ballerina"
name = "http_test_common"
version = "2.7.7"
version = "2.7.8"
scope = "testOnly"
dependencies = [
{org = "ballerina", name = "lang.string"},
Expand Down
Loading

0 comments on commit 915c96e

Please sign in to comment.