Giter Club home page Giter Club logo

httpretty's Introduction

httpretty's People

Contributors

anthonyfok avatar henvic avatar mislav avatar zhsj avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

httpretty's Issues

TestOutgoingTLSInvalidCertificate fails on Go1.20

$ go test -run TestOutgoingTLSInvalidCertificate
--- FAIL: TestOutgoingTLSInvalidCertificate (0.02s)
    client_test.go:1342: logged HTTP request * Request to https://127.0.0.1:42873
        > GET / HTTP/1.1
        > Host: example.com
        > User-Agent: Robot/0.1 [email protected]
        
        * tls: failed to verify certificate: x509: certificate signed by unknown authority
        ; want ^\* Request to https://127.0.0.1:42873
        > GET / HTTP/1\.1
        > Host: example\.com
        > User-Agent: Robot/0\.1 crawler@example\.com
        
        \* x509: .+
FAIL

Seems Go1.20 changes the error message again.

Request path interpreted as format string

Making a request with a query parameter with value foo & bar results in something like this being printed:

> POST /mypath?label=foo+%!+(MISSING)bar HTTP/1.1

This is because the & character gets %-encoded when in a URL, and color.Format() interprets anything passed to it as a format string. Any value that could potentially have a literal % character in it (any dynamic or user-defined value, really) should never be used a sprintf format string.

Don't try to print logs for mediatypes such as application/octet-stream, images, etc.

This can be done both by identifying Content-Type and by inspecting file magic numbers to identify if a file is "binary" or not. Decide what to use (probably both).

Maybe we can introduce an internal Formatter implementation that identifies the file by matching mime-type and this might be good at first (and use a second step to identify other cases to avoid printing rubbish). However, we might want to identify it earlier and avoid some processing.

TestOutgoingTLSBadClientCertificate seems flaky on Travis CI

From https://travis-ci.org/henvic/httpretty/jobs/645236419

--- FAIL: TestOutgoingTLSBadClientCertificate (0.03s)
262    client_test.go:1411: logged HTTP request * Request to https://127.0.0.1:35251
263        * Client certificate:
264        *  subject: CN=User,OU=User,O=Client,L=Rotterdam,ST=Zuid-Holland,C=NL
265        *  start date: Sat Jan 25 20:12:36 UTC 2020
266        *  expire date: Mon Jan  1 20:12:36 UTC 2120
267        *  issuer: CN=User,OU=User,O=Client,L=Rotterdam,ST=Zuid-Holland,C=NL
268        > GET / HTTP/1.1
269        > Host: example.com
270        > User-Agent: Robot/0.1 [email protected]
271        
272        * readLoopPeekFailLocked: remote error: tls: bad certificate
273        ; want * Request to https://127.0.0.1:35251
274        * Client certificate:
275        *  subject: CN=User,OU=User,O=Client,L=Rotterdam,ST=Zuid-Holland,C=NL
276        *  start date: Sat Jan 25 20:12:36 UTC 2020
277        *  expire date: Mon Jan  1 20:12:36 UTC 2120
278        *  issuer: CN=User,OU=User,O=Client,L=Rotterdam,ST=Zuid-Holland,C=NL
279        > GET / HTTP/1.1
280        > Host: example.com
281        > User-Agent: Robot/0.1 [email protected]
282        
283        * remote error: tls: bad certificate

Custom header sanitization

I have a module that calls an API with a custom authorization header. I would like to sanitize it rather than hide it, but currently doesn't appear I can do so. The ability to add additional headers for sanitization would be a great addition.

Let user hide unwanted headers

On cli/cli#306 (review) @mislav asked me for

a way to avoid certain request/response headers being printed; perhaps accept a func that takes a header name and returns a boolean that indicates whether to print or not?

This might be achieved with a function similar to SetFilter and SetBodyFilter. It might take a slice and store the data in a map[string]struct{} to be checked when printing headers.

Probably can be called FilterHeader or FilterHeaders.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.