Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename "DNS-lookup" to "DNS lookup" (fixes #123) #125

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ngrilly
Copy link

@ngrilly ngrilly commented Sep 6, 2018

"DNS-lookup" could be interpreted as "DNS lookup duration minus some other lookup duration". This change removes the ambiguity.

"DNS-lookup" could be interpreted as "DNS lookup duration minus some other lookup duration". This change removes the ambiguity.
chunter0 pushed a commit to chunter0/hey that referenced this pull request Apr 8, 2024
When a request to `/anything` has an empty body, the `data` field of the
output should be the empty string. Currently, `go-httpbin is returning
`data:application/octet-stream;base64,`.

- Should the output actually be null? That would match `files`, `form`,
and `json`, but also would require deeper changes since `Data` is stored
as a string not a pointer, and I didn't want to mess with things any
more than I had to. An empty string works fine for my purposes
- how can I test this PR? I tried but I got confused by the TestAnything
method
- all the current tests pass under this change

This PR closes rakyll#124. Before:

```
$ curl -s 'http://0.0.0.0:8080/anything?one=two'
{
  "args": {
    "one": [
      "two"
    ]
  },
  "headers": {
    "Accept": [
      "*/*"
    ],
    "Host": [
      "0.0.0.0:8080"
    ],
    "User-Agent": [
      "curl/7.88.1"
    ]
  },
  "method": "GET",
  "origin": "127.0.0.1:60402",
  "url": "http://0.0.0.0:8080/anything?one=two",
  "data": "data:application/octet-stream;base64,",
  "files": null,
  "form": null,
  "json": null
}
```

After:
```
$ curl -s 'http://0.0.0.0:8080/anything?one=two'
{
  "args": {
    "one": [
      "two"
    ]
  },
  "headers": {
    "Accept": [
      "*/*"
    ],
    "Host": [
      "0.0.0.0:8080"
    ],
    "User-Agent": [
      "curl/7.88.1"
    ]
  },
  "method": "GET",
  "origin": "127.0.0.1:60595",
  "url": "http://0.0.0.0:8080/anything?one=two",
  "data": "",
  "files": null,
  "form": null,
  "json": null
}
```
chunter0 pushed a commit to chunter0/hey that referenced this pull request Apr 8, 2024
In the course of validating rakyll#125, we discovered that using the stdlib's
[`httptest.ResponseRecorder`][0] mechanism to drive the vast majority of
our unit tests led to some slight brokenness due to subtle differences
in the way those "simulated" requests are handled vs "real" requests to
a live HTTP server, as [explained in this comment][1].

That prompted me to do a big ass refactor of the entire test suite,
swapping httptest.ResponseRecorder for interacting with a live server
instance via [`httptest.Server`][2].

This should make the test suite more accurate and reliable in the long
run by ensuring that the vast majority of tests are making actual HTTP
requests and reading responses from the wire.

Note that updating these tests also uncovered a few minor bugs in
existing handler code, fixed in a separate commit for visibility.

P.S. I'm awfully sorry to anyone who tries to merge or rebase local test
changes after this refactor lands, that is goign to be a nightmare. If
you run into issues resolving conflicts, feel free to ping me and I can
try to help!

[0]: https://pkg.go.dev/net/http/httptest#ResponseRecorder
[1]: mccutchen/go-httpbin#125 (comment)
[2]: https://pkg.go.dev/net/http/httptest#Server
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant