Skip to content

Conversation

timkaye11
Copy link

In order to enable mock testing, we currently replace the http.DefaultTransport with the mock transport in the Activate function. However, we run into errors when we use clients other than http.DefaultClient (which uses the default transport). In order to handle non-default clients, this PR introduces the ActivateNonDefault function, which replaces custom the http.Transport with the mock transport for custom http.Clients.

Also bumped travis to the newest version and added a unit test for the new function.

@pires
Copy link
Contributor

pires commented Jul 29, 2015

+1

@timkaye11 Can this be used to work with github.com/parnurzeal/gorequest?

@timkaye11
Copy link
Author

@pires I believe so - you'd just have to call ActivateNonDefault(s.Client) where s is the SuperAgent. https://github.com/parnurzeal/gorequest/blob/master/main.go#L565

@pires
Copy link
Contributor

pires commented Jul 29, 2015

@timkaye11 didn't work.

@pires
Copy link
Contributor

pires commented Jul 29, 2015

@timkaye11 what is now obvious to me is that I had to comment the line you linked and it worked. Ofc, commenting said line will break runtime.

jarcoal added a commit that referenced this pull request Aug 1, 2015
Be able to handle non-default http clients
@jarcoal jarcoal merged commit 7d5b5c4 into jarcoal:master Aug 1, 2015
@jarcoal
Copy link
Owner

jarcoal commented Aug 1, 2015

@timkaye11 thanks!

constantoine added a commit to constantoine/httpmock that referenced this pull request Nov 14, 2024
Although RFC 2616 has been superseded with RFC 9110, some client implementation still rely on certain behavious regarding the Status-Line.

Now, as httpmock currently implements it, per [RFC 9110#6.2-1](https://www.rfc-editor.org/rfc/rfc9110.html#section-6.2-1), the "reason phrase" is actually optional, and you need only to include the status code.

Back in the days of [RFC 2616](https://www.rfc-editor.org/rfc/rfc2616.html#section-6.1), per jarcoal#6.1, the Status-Line had to contain both the status code (eg. 200) and its textual representation (eg. OK).

Change code is directly stolen from the Go standard library.

Signed-off-by: Cléo Rebert <cleo.rebert@gmail.com>
constantoine added a commit to constantoine/httpmock that referenced this pull request Nov 14, 2024
Although RFC 2616 has been superseded with RFC 9110, some client implementation still rely on certain behavious regarding the Status-Line.

Now, as httpmock currently implements it, per [RFC 9110#6.2-1](https://www.rfc-editor.org/rfc/rfc9110.html#section-6.2-1), the "reason phrase" is actually optional, and you need only to include the status code.

Back in the days of [RFC 2616](https://www.rfc-editor.org/rfc/rfc2616.html#section-6.1), per jarcoal#6.1, the Status-Line had to contain both the status code (eg. 200) and its textual representation (eg. OK).

Change code is directly stolen from the Go standard library.

Signed-off-by: Cléo Rebert <cleo.rebert@gmail.com>
maxatome pushed a commit that referenced this pull request Nov 14, 2024
Although RFC 2616 has been superseded with RFC 9110, some client implementation still rely on certain behavious regarding the Status-Line.

Now, as httpmock currently implements it, per [RFC 9110#6.2-1](https://www.rfc-editor.org/rfc/rfc9110.html#section-6.2-1), the "reason phrase" is actually optional, and you need only to include the status code.

Back in the days of [RFC 2616](https://www.rfc-editor.org/rfc/rfc2616.html#section-6.1), per #6.1, the Status-Line had to contain both the status code (eg. 200) and its textual representation (eg. OK).

Change code is directly stolen from the Go standard library.

Signed-off-by: Cléo Rebert <cleo.rebert@gmail.com>
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.

3 participants