Skip to content
Snippets Groups Projects
  1. Jun 18, 2023
    • Bill Mill's avatar
      fix: return empty data field for empty request bodies (#125) · a70a8478
      Bill Mill authored
      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 #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
      }
      ```
    • Bill Mill's avatar
      feat: add method property to responses (#123) · 1223a736
      Bill Mill authored
      ```console
      # before: httpbingo lacks the "method" field but httpbin.org has it
      $ curl -s https://httpbingo.org/anything | jq .method                                                                                                        9:31PM
      null
      $ curl -s https://httpbin.org/anything | jq .method
      "GET"
      
      # after: httpbingo has the method field!
      $ curl -s http://0.0.0.0:8080/anything | jq .method
      "GET"
      ```
      
      This was mentioned in #6, but then not listed in #91
      
      - I took the highly technical testing approach of adding a test for
      `Method` anywhere in `handlers_test.go` that mentioned `Args`; do you
      desire more tests? fewer tests?
      - Anywhere else I should add this field that I didn't already?
      
      For what it's worth, I discovered this when working on upgrading the
      testing for our [httpsnippet
      library](https://github.com/readmeio/httpsnippet); I wanted to use
      `go-httpbin` but our tests expect the method field to be present in the
      responses
      1223a736
  2. May 05, 2023
  3. May 02, 2023
  4. Apr 14, 2023
    • Will McCutchen's avatar
      Build & CI updates (#116) · c9f5002d
      Will McCutchen authored
      A few small tweaks:
      - Simplify makefile
      - Cancel in-progress CI jobs when new commits are pushed to a non-main
      branch
      - Drop manual codeql config now that GitHub supports automagical
      configuration
      c9f5002d
  5. Mar 13, 2023
  6. Feb 15, 2023
  7. Jan 31, 2023
  8. Jan 30, 2023
  9. Jan 17, 2023
  10. Nov 19, 2022
    • Will McCutchen's avatar
      Improve tests for streaming response endpoints (#105) · 1229cc69
      Will McCutchen authored
      A few small improvements to the test suite:
      - Ensure `/stream` and `/stream-bytes` endpoints actually use
      `Transfer-Encoding: chunked`, instead of inferring/hoping based on
      Content-Length header
      - Explicitly test that `/drip` actually does sleep between writing
      bytes, rather than inferring that it does based on entire response
      duration
      1229cc69
  11. Nov 16, 2022
  12. Nov 13, 2022
  13. Nov 11, 2022
  14. Oct 19, 2022
    • Will McCutchen's avatar
      More comprehensive tests for HTTP verb endpoints (#88) · 4ec6c82f
      Will McCutchen authored
      We were not explicitly testing the behavior of some HTTP verb endpoints
      like /put and /patch, because they currently share an underlying handler
      with /post which is thoroughly tested.
      
      The addition of the /anything endpoint in #83 made me realize a bit more
      explicit test coverage would be good, so here we're landing a bit of a
      refactoring of the test suite to generate tests for all of those
      endpoints.
      
      Along the way, we also improve compatibility with the original httpbin
      implementation by tricking the stdlib net/http machinery into parsing
      request bodies for DELETE requests.
      4ec6c82f
  15. Oct 17, 2022
  16. Oct 13, 2022
  17. Oct 12, 2022
  18. Jul 24, 2022
  19. Jul 08, 2022
  20. Jul 05, 2022
  21. Apr 07, 2022
  22. Apr 01, 2022
Loading