Skip to content

Commit

Permalink
Fix timeout panic (grpc-ecosystem#2823)
Browse files Browse the repository at this point in the history
* Handle nil contexts in Context methods

This will fix grpc-ecosystem#2822 for users who only update their runtime

* Avoid passing nil context to runtime.HTTPError

This will fix grpc-ecosystem#2822 for users who only update their generator
  • Loading branch information
johanbrandhorst authored Jul 30, 2022
1 parent 1911ac0 commit a3a0b21
Show file tree
Hide file tree
Showing 19 changed files with 1,453 additions and 1,187 deletions.
220 changes: 120 additions & 100 deletions examples/internal/helloworld/helloworld.pb.gw.go

Large diffs are not rendered by default.

33 changes: 29 additions & 4 deletions examples/internal/integration/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1574,6 +1574,31 @@ func TestTimeout(t *testing.T) {
}
}

func TestInvalidTimeout(t *testing.T) {
if testing.Short() {
t.Skip()
return
}

apiURL := "http://localhost:8088/v2/example/timeout"
req, err := http.NewRequest("GET", apiURL, nil)
if err != nil {
t.Errorf(`http.NewRequest("GET", %q, nil) failed with %v; want success`, apiURL, err)
return
}
req.Header.Set("Grpc-Timeout", "INVALID")
resp, err := http.DefaultClient.Do(req)
if err != nil {
t.Errorf("http.DefaultClient.Do(%#v) failed with %v; want success", req, err)
return
}
defer resp.Body.Close()

if got, want := resp.StatusCode, http.StatusBadRequest; got != want {
t.Errorf("resp.StatusCode = %d; want %d", got, want)
}
}

func TestPostWithEmptyBody(t *testing.T) {
if testing.Short() {
t.Skip()
Expand Down Expand Up @@ -2359,8 +2384,8 @@ func testABEOptions(t *testing.T, port int) {
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
t.Fatal(err)
}
t.Fatal(err)
}
defer resp.Body.Close()
if got, want := resp.StatusCode, http.StatusOK; got != want {
t.Errorf("resp.StatusCode = %d; want %d", got, want)
Expand All @@ -2387,8 +2412,8 @@ func testABETrace(t *testing.T, port int) {
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
t.Fatal(err)
}
t.Fatal(err)
}
defer resp.Body.Close()
buf, err := ioutil.ReadAll(resp.Body)
if err != nil {
Expand Down
704 changes: 384 additions & 320 deletions examples/internal/proto/examplepb/a_bit_of_everything.pb.gw.go

Large diffs are not rendered by default.

220 changes: 120 additions & 100 deletions examples/internal/proto/examplepb/echo_service.pb.gw.go

Large diffs are not rendered by default.

418 changes: 228 additions & 190 deletions examples/internal/proto/examplepb/flow_combination.pb.gw.go

Large diffs are not rendered by default.

66 changes: 36 additions & 30 deletions examples/internal/proto/examplepb/generate_unbound_methods.pb.gw.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

44 changes: 24 additions & 20 deletions examples/internal/proto/examplepb/non_standard_names.pb.gw.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit a3a0b21

Please sign in to comment.