Skip to content

Commit d8bfab6

Browse files
author
Erich Shan
committed
add debug printing
1 parent 090bfbc commit d8bfab6

File tree

4 files changed

+35
-4
lines changed

4 files changed

+35
-4
lines changed

config/crd/bases/http.keda.sh_httpscaledobjects.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,6 @@ spec:
9797
- name
9898
- value
9999
type: array
100-
uniqueItems: true
101100
replicas:
102101
description: (optional) Replica information
103102
properties:

interceptor/middleware/routing.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,9 @@ var _ http.Handler = (*Routing)(nil)
4343
func (rm *Routing) ServeHTTP(w http.ResponseWriter, r *http.Request) {
4444
r = util.RequestWithLoggerWithName(r, "RoutingMiddleware")
4545

46+
// logger := util.LoggerFromContext(r.Context())
4647
httpso := rm.routingTable.Route(r)
48+
4749
if httpso == nil {
4850
if rm.isProbe(r) {
4951
rm.probeHandler.ServeHTTP(w, r)

operator/apis/http/v1alpha1/zz_generated.deepcopy.go

Lines changed: 25 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/routing/tablememory.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
package routing
22

33
import (
4+
"fmt"
5+
"net/textproto"
6+
47
"k8s.io/apimachinery/pkg/types"
58

69
httpv1alpha1 "github.com/kedacore/http-add-on/operator/apis/http/v1alpha1"
@@ -103,11 +106,15 @@ func (tm tableMemory) RouteWithHeaders(key Key, httpHeaders map[string][]string)
103106
return httpsoList.Items[0]
104107
}
105108
var httpsoWithoutHeaders *httpv1alpha1.HTTPScaledObject
109+
106110
// route to first httpso which has a matching header
107111
for _, httpso := range httpsoList.Items {
108112
if httpso.Spec.Headers != nil {
109113
for _, header := range httpso.Spec.Headers {
110-
if headerValues, exists := httpHeaders[header.Name]; exists {
114+
// normalize header spacing how golang does it
115+
canonicalHeaderName := textproto.CanonicalMIMEHeaderKey(header.Name)
116+
fmt.Println("canonical headername", canonicalHeaderName)
117+
if headerValues, exists := httpHeaders[canonicalHeaderName]; exists {
111118
for _, v := range headerValues {
112119
if header.Value == v {
113120
return httpso
@@ -124,7 +131,6 @@ func (tm tableMemory) RouteWithHeaders(key Key, httpHeaders map[string][]string)
124131
if httpsoWithoutHeaders != nil {
125132
return httpsoWithoutHeaders
126133
}
127-
128134
// otherwise routing fails
129135
return nil
130136
}

0 commit comments

Comments
 (0)