Skip to content

Commit

Permalink
go get knative.dev/[email protected] (#1076)
Browse files Browse the repository at this point in the history
go mod vendor
make generate-release

Signed-off-by: Calum Murray <[email protected]>
  • Loading branch information
Cali0707 authored May 6, 2024
1 parent 7989c29 commit 145e6fb
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 5 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ require (
knative.dev/eventing v0.40.2-0.20240220123738-40637813ad8d
knative.dev/hack v0.0.0-20240123162936-f3f03ac0ab1a
knative.dev/pkg v0.0.0-20240116073220-b488e7be5902
knative.dev/reconciler-test v0.0.0-20240206112124-e5d2639d7c5c
knative.dev/reconciler-test v0.0.0-20240503125940-3f5c8e26233f
sigs.k8s.io/controller-runtime v0.12.3
sigs.k8s.io/yaml v1.4.0
)
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1282,8 +1282,8 @@ knative.dev/hack v0.0.0-20240123162936-f3f03ac0ab1a h1:+4Mdk0Lt3LGAVEI6vYyhfjBlV
knative.dev/hack v0.0.0-20240123162936-f3f03ac0ab1a/go.mod h1:yk2OjGDsbEnQjfxdm0/HJKS2WqTLEFg/N6nUs6Rqx3Q=
knative.dev/pkg v0.0.0-20240116073220-b488e7be5902 h1:H6+JJN23fhwYWCHY1339sY6uhIyoUwDy1a8dN233fdk=
knative.dev/pkg v0.0.0-20240116073220-b488e7be5902/go.mod h1:NYk8mMYoLkO7CQWnNkti4YGGnvLxN6MIDbUvtgeo0C0=
knative.dev/reconciler-test v0.0.0-20240206112124-e5d2639d7c5c h1:aFTcLeISFwAv6F8ACidQ8RszREI16ax0PkTsGVibdoI=
knative.dev/reconciler-test v0.0.0-20240206112124-e5d2639d7c5c/go.mod h1:PdI3uCI/8URA+hyBvWqZ2pwCIvX/4/nqCNsdW1cQauM=
knative.dev/reconciler-test v0.0.0-20240503125940-3f5c8e26233f h1:Je31aZRlbSXicZmebrhELIasljV/79p9E2K1uTnsEfg=
knative.dev/reconciler-test v0.0.0-20240503125940-3f5c8e26233f/go.mod h1:PdI3uCI/8URA+hyBvWqZ2pwCIvX/4/nqCNsdW1cQauM=
pgregory.net/rapid v1.1.0 h1:CMa0sjHSru3puNx+J0MIAuiiEV4N0qj8/cMWGBBCsjw=
pgregory.net/rapid v1.1.0/go.mod h1:PY5XlDGj0+V1FCq0o192FdRhpKHGTRIWBgqjDBTrq04=
rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8=
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@ limitations under the License.
package forwarder

import (
"bytes"
"context"
"fmt"
"io"
"io/ioutil"
"net/http"
"net/url"
Expand Down Expand Up @@ -126,10 +128,21 @@ func (o *Forwarder) ServeHTTP(writer http.ResponseWriter, request *http.Request)
requestCtx, span := trace.StartSpan(request.Context(), "eventshub-forwarder")
defer span.End()

body, err := io.ReadAll(request.Body)
if err != nil {
writer.WriteHeader(http.StatusInternalServerError)
logging.FromContext(o.ctx).Errorw("Failed to read request body", zap.Error(err))
return
}
_ = request.Body.Close()
request.Body = io.NopCloser(bytes.NewBuffer(body))

m := cloudeventshttp.NewMessageFromHttpRequest(request)
defer m.Finish(nil)

event, eventErr := cloudeventsbindings.ToEvent(context.TODO(), m)
request.Body = io.NopCloser(bytes.NewBuffer(body)) // reset body

receivedHeaders := make(http.Header)
for k, v := range request.Header {
if !strings.HasPrefix(k, "Ce-") {
Expand Down Expand Up @@ -164,6 +177,8 @@ func (o *Forwarder) ServeHTTP(writer http.ResponseWriter, request *http.Request)
req := request.Clone(requestCtx)
// It is an error to set this field in an HTTP client request.
req.RequestURI = ""
// We don't want to use the original request Host header, so drop it from the clone
req.Host = ""

u, err := url.Parse(o.Sink)
if err != nil {
Expand Down Expand Up @@ -194,7 +209,7 @@ func (o *Forwarder) ServeHTTP(writer http.ResponseWriter, request *http.Request)
}
}

writer.WriteHeader(http.StatusAccepted)
writer.WriteHeader(res.StatusCode)
}

func (o *Forwarder) sentInfo(event *cloudevents.Event, req *http.Request, err error) eventshub.EventInfo {
Expand Down
2 changes: 1 addition & 1 deletion vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1617,7 +1617,7 @@ knative.dev/pkg/webhook/json
knative.dev/pkg/webhook/resourcesemantics
knative.dev/pkg/webhook/resourcesemantics/defaulting
knative.dev/pkg/webhook/resourcesemantics/validation
# knative.dev/reconciler-test v0.0.0-20240206112124-e5d2639d7c5c
# knative.dev/reconciler-test v0.0.0-20240503125940-3f5c8e26233f
## explicit; go 1.20
knative.dev/reconciler-test/cmd/eventshub
knative.dev/reconciler-test/pkg/environment
Expand Down

0 comments on commit 145e6fb

Please sign in to comment.