MCPcopy
hub / github.com/labstack/echo / TestContext_Scheme

Function TestContext_Scheme

context_test.go:1092–1263  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1090}
1091
1092func TestContext_Scheme(t *testing.T) {
1093 var testCases = []struct {
1094 name string
1095 givenIsTLS bool
1096 givenHeaders http.Header
1097 expect string
1098 }{
1099 {
1100 name: "defaults to http without TLS or headers",
1101 givenIsTLS: false,
1102 givenHeaders: nil,
1103 expect: "http",
1104 },
1105 {
1106 name: "returns https when TLS is enabled",
1107 givenIsTLS: true,
1108 givenHeaders: nil,
1109 expect: "https",
1110 },
1111 {
1112 name: "TLS takes precedence over forwarded proto",
1113 givenIsTLS: true,
1114 givenHeaders: http.Header{
1115 HeaderXForwardedProto: []string{"http"},
1116 },
1117 expect: "https",
1118 },
1119 {
1120 name: "uses X-Forwarded-Proto http",
1121 givenIsTLS: false,
1122 givenHeaders: http.Header{
1123 HeaderXForwardedProto: []string{"http"},
1124 },
1125 expect: "http",
1126 },
1127 {
1128 name: "uses X-Forwarded-Proto https",
1129 givenIsTLS: false,
1130 givenHeaders: http.Header{
1131 HeaderXForwardedProto: []string{"https"},
1132 },
1133 expect: "https",
1134 },
1135 {
1136 name: "X-Forwarded-Proto is case insensitive",
1137 givenIsTLS: false,
1138 givenHeaders: http.Header{
1139 HeaderXForwardedProto: []string{"HTTPS"},
1140 },
1141 expect: "HTTPS",
1142 },
1143 {
1144 name: "uses X-Forwarded-Proto ws",
1145 givenIsTLS: false,
1146 givenHeaders: http.Header{
1147 HeaderXForwardedProto: []string{"ws"},
1148 },
1149 expect: "ws",

Callers

nothing calls this directly

Calls 2

SchemeMethod · 0.95
NewContextFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…