From 67240ae09fd3d601a03ffdb404bbd9875996d43c Mon Sep 17 00:00:00 2001 From: ICHINOSE Shogo Date: Fri, 2 Feb 2024 16:26:31 +0900 Subject: [PATCH 1/2] add test for isBinary --- ridgenative_test.go | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/ridgenative_test.go b/ridgenative_test.go index 787e497..53f7850 100644 --- a/ridgenative_test.go +++ b/ridgenative_test.go @@ -949,3 +949,28 @@ func TestLambdaHandlerStreaming(t *testing.T) { } }) } + +func TestIsBinary(t *testing.T) { + tests := []struct { + contentType string + want bool + }{ + {"text/html", false}, + {"text/plain", false}, + {"text/xml", false}, + {"application/json", false}, + {"application/javascript", false}, + {"application/xml", false}, + {"application/foo+json", false}, + {"application/foo+xml", false}, + {"application/foo+xml ; charset=utf8", false}, + {"application/octet-stream", true}, + } + + for _, tt := range tests { + got := isBinary(tt.contentType) + if got != tt.want { + t.Errorf("isBinary(%q) = %v, want %v", tt.contentType, got, tt.want) + } + } +} From 7d323f4461bfa531d7a8d25546a9e7ddb7773e13 Mon Sep 17 00:00:00 2001 From: ICHINOSE Shogo Date: Fri, 2 Feb 2024 16:32:19 +0900 Subject: [PATCH 2/2] add common binary content types --- ridgenative_test.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ridgenative_test.go b/ridgenative_test.go index 53f7850..810548b 100644 --- a/ridgenative_test.go +++ b/ridgenative_test.go @@ -965,6 +965,10 @@ func TestIsBinary(t *testing.T) { {"application/foo+xml", false}, {"application/foo+xml ; charset=utf8", false}, {"application/octet-stream", true}, + {"image/jpeg", true}, + {"audio/mpeg", true}, + {"unknown-content-type", true}, + {"", true}, } for _, tt := range tests {