Skip to content

Commit

Permalink
Use Content-Type application/cloudevents+json for http provider (#415)
Browse files Browse the repository at this point in the history
* Use Content-Type application/cloudevents+json for http provider

* gofmt
  • Loading branch information
alexdebrie authored and mthenw committed Apr 27, 2018
1 parent e75ed0c commit 5bf5be8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion providers/http/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func (h HTTP) Call(payload []byte) ([]byte, error) {
Timeout: time.Second * 5,
}

resp, err := client.Post(h.URL, "application/json", bytes.NewReader(payload))
resp, err := client.Post(h.URL, "application/cloudevents+json", bytes.NewReader(payload))
if err != nil {
return nil, &function.ErrFunctionCallFailed{Original: err}
}
Expand Down
3 changes: 3 additions & 0 deletions providers/http/http_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ func TestLoad(t *testing.T) {
}

func TestCall(t *testing.T) {
var contentType string
echo := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
contentType = r.Header.Get("Content-Type")
payload, _ := ioutil.ReadAll(r.Body)
defer r.Body.Close()
fmt.Fprint(w, string(payload))
Expand All @@ -34,6 +36,7 @@ func TestCall(t *testing.T) {
resp, err := provider.Call([]byte("hello"))

assert.Nil(t, err)
assert.Equal(t, "application/cloudevents+json", contentType)
assert.Equal(t, "hello", string(resp))
}

Expand Down

0 comments on commit 5bf5be8

Please sign in to comment.