$69 GRAYBYTE WORDPRESS FILE MANAGER $59

SERVER : in-mum-web1330.main-hosting.eu #1 SMP Mon Feb 10 22:45:17 UTC 2025
SERVER IP : 2.57.91.66 | ADMIN IP 216.73.216.215
OPTIONS : CRL = ON | WGT = ON | SDO = OFF | PKEX = OFF
DEACTIVATED : NONE

/opt/go/pkg/mod/github.com/go-openapi/runtime@v0.26.0/

HOME
Current File : /opt/go/pkg/mod/github.com/go-openapi/runtime@v0.26.0//headers_test.go
// Copyright 2015 go-swagger maintainers
//
// Licensed 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 runtime

import (
	"mime"
	"net/http"
	"testing"

	"github.com/go-openapi/errors"
	"github.com/stretchr/testify/assert"
)

func TestParseContentType(t *testing.T) {
	_, _, reason1 := mime.ParseMediaType("application(")
	_, _, reason2 := mime.ParseMediaType("application/json;char*")
	data := []struct {
		hdr, mt, cs string
		err         *errors.ParseError
	}{
		{"application/json", "application/json", "", nil},
		{"text/html; charset=utf-8", "text/html", "utf-8", nil},
		{"text/html;charset=utf-8", "text/html", "utf-8", nil},
		{"", "application/octet-stream", "", nil},
		{"text/html;           charset=utf-8", "text/html", "utf-8", nil},
		{"application(", "", "", errors.NewParseError("Content-Type", "header", "application(", reason1)},
		{"application/json;char*", "", "", errors.NewParseError("Content-Type", "header", "application/json;char*", reason2)},
	}

	headers := http.Header(map[string][]string{})
	for _, v := range data {
		if v.hdr != "" {
			headers.Set("Content-Type", v.hdr)
		} else {
			headers.Del("Content-Type")
		}
		ct, cs, err := ContentType(headers)
		if v.err == nil {
			assert.NoError(t, err, "input: %q, err: %v", v.hdr, err)
		} else {
			assert.Error(t, err, "input: %q", v.hdr)
			assert.IsType(t, &errors.ParseError{}, err, "input: %q", v.hdr)
			assert.Equal(t, v.err.Error(), err.Error(), "input: %q", v.hdr)
		}
		assert.Equal(t, v.mt, ct, "input: %q", v.hdr)
		assert.Equal(t, v.cs, cs, "input: %q", v.hdr)
	}
}

Current_dir [ NOT WRITEABLE ] Document_root [ WRITEABLE ]


[ Back ]
NAME
SIZE
LAST TOUCH
USER
CAN-I?
FUNCTIONS
..
--
25 Jan 2024 4.43 PM
root / root
0755
.github
--
25 Jan 2024 4.43 PM
root / root
0555
client
--
25 Jan 2024 4.43 PM
root / root
0555
fixtures
--
25 Jan 2024 4.43 PM
root / root
0555
flagext
--
25 Jan 2024 4.43 PM
root / root
0555
hack
--
25 Jan 2024 4.43 PM
root / root
0555
internal
--
25 Jan 2024 4.43 PM
root / root
0555
logger
--
25 Jan 2024 4.43 PM
root / root
0555
middleware
--
25 Jan 2024 4.43 PM
root / root
0555
security
--
25 Jan 2024 4.43 PM
root / root
0555
yamlpc
--
25 Jan 2024 4.43 PM
root / root
0555
.editorconfig
0.526 KB
25 Jan 2024 4.43 PM
root / root
0444
.gitattributes
0.017 KB
25 Jan 2024 4.43 PM
root / root
0444
.gitignore
0.047 KB
25 Jan 2024 4.43 PM
root / root
0444
.golangci.yml
0.699 KB
25 Jan 2024 4.43 PM
root / root
0444
CODE_OF_CONDUCT.md
3.157 KB
25 Jan 2024 4.43 PM
root / root
0444
LICENSE
11.092 KB
25 Jan 2024 4.43 PM
root / root
0444
README.md
0.705 KB
25 Jan 2024 4.43 PM
root / root
0444
authinfo_test.go
1.071 KB
25 Jan 2024 4.43 PM
root / root
0444
bytestream.go
4.137 KB
25 Jan 2024 4.43 PM
root / root
0444
bytestream_test.go
6.246 KB
25 Jan 2024 4.43 PM
root / root
0444
client_auth_info.go
1.16 KB
25 Jan 2024 4.43 PM
root / root
0444
client_operation.go
1.366 KB
25 Jan 2024 4.43 PM
root / root
0444
client_request.go
3.655 KB
25 Jan 2024 4.43 PM
root / root
0444
client_request_test.go
1.113 KB
25 Jan 2024 4.43 PM
root / root
0444
client_response.go
3.201 KB
25 Jan 2024 4.43 PM
root / root
0444
client_response_test.go
2.477 KB
25 Jan 2024 4.43 PM
root / root
0444
constants.go
1.664 KB
25 Jan 2024 4.43 PM
root / root
0444
csv.go
1.865 KB
25 Jan 2024 4.43 PM
root / root
0444
csv_test.go
1.764 KB
25 Jan 2024 4.43 PM
root / root
0444
discard.go
0.329 KB
25 Jan 2024 4.43 PM
root / root
0444
file.go
0.659 KB
25 Jan 2024 4.43 PM
root / root
0444
file_test.go
0.584 KB
25 Jan 2024 4.43 PM
root / root
0444
go.mod
1.254 KB
25 Jan 2024 4.43 PM
root / root
0444
go.sum
19.355 KB
25 Jan 2024 4.43 PM
root / root
0444
headers.go
1.114 KB
25 Jan 2024 4.43 PM
root / root
0444
headers_test.go
2.018 KB
25 Jan 2024 4.43 PM
root / root
0444
interfaces.go
3.99 KB
25 Jan 2024 4.43 PM
root / root
0444
json.go
1.117 KB
25 Jan 2024 4.43 PM
root / root
0444
json_test.go
1.471 KB
25 Jan 2024 4.43 PM
root / root
0444
request.go
3.33 KB
25 Jan 2024 4.43 PM
root / root
0444
request_test.go
5.06 KB
25 Jan 2024 4.43 PM
root / root
0444
statuses.go
2.515 KB
25 Jan 2024 4.43 PM
root / root
0444
text.go
2.821 KB
25 Jan 2024 4.43 PM
root / root
0444
text_test.go
4.952 KB
25 Jan 2024 4.43 PM
root / root
0444
values.go
0.483 KB
25 Jan 2024 4.43 PM
root / root
0444
values_test.go
0.596 KB
25 Jan 2024 4.43 PM
root / root
0444
xml.go
1.038 KB
25 Jan 2024 4.43 PM
root / root
0444
xml_test.go
1.438 KB
25 Jan 2024 4.43 PM
root / root
0444

GRAYBYTE WORDPRESS FILE MANAGER @ 2026 CONTACT ME
Static GIF