-
-
Notifications
You must be signed in to change notification settings - Fork 11k
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
Make redirection from HTTP to HTTPS work #2426
Merged
Merged
+4
−0
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
When calling an HTTP resource redirecting to a HTTPS one with a keepAlive agent. We get the following error: ``` TypeError [ERR_INVALID_PROTOCOL]: Protocol "https:" not supported. Expected "http:" at new ClientRequest (_http_client.js:119:11) at Object.request (https.js:281:10) at RedirectableRequest._performRequest (/Users/jthomassey/projects/ecom-shop-web/node_modules/follow-redirects/index.js:169:24) at RedirectableRequest._processResponse (/Users/jthomassey/projects/ecom-shop-web/node_modules/follow-redirects/index.js:260:10) at ClientRequest.RedirectableRequest._onNativeResponse (/Users/jthomassey/projects/ecom-shop-web/node_modules/follow-redirects/index.js:50:10) at Object.onceWrapper (events.js:277:13) at ClientRequest.emit (events.js:189:13) at HTTPParser.parserOnIncomingClient [as onIncoming] (_http_client.js:556:21) at HTTPParser.parserOnHeadersComplete (_http_common.js:109:17) at Socket.socketOnData (_http_client.js:442:20) ``` This can be tested here : ``` const http = require('http'); const https = require('https'); const axios = require('axios'); axios.get('http://www.photobox.fr', { httpAgent: http.Agent({ keepAlive:true }), httpsAgent: https.Agent({ keepAlive:true }) }) .then(response => { console.log(response); console.log(response.headers); }) .catch(error => { console.log(error); }); ``` Axios delegate the redirection to the follow-redirect package which accept an option `agents` for both http and https agent see : https://github.com/follow-redirects/follow-redirects#per-request-options
Great stuff 👍 |
genie-youn
pushed a commit
to genie-youn/axios
that referenced
this pull request
Sep 27, 2019
When calling an HTTP resource redirecting to a HTTPS one with a keepAlive agent. We get the following error: ``` TypeError [ERR_INVALID_PROTOCOL]: Protocol "https:" not supported. Expected "http:" at new ClientRequest (_http_client.js:119:11) at Object.request (https.js:281:10) at RedirectableRequest._performRequest (/Users/jthomassey/projects/ecom-shop-web/node_modules/follow-redirects/index.js:169:24) at RedirectableRequest._processResponse (/Users/jthomassey/projects/ecom-shop-web/node_modules/follow-redirects/index.js:260:10) at ClientRequest.RedirectableRequest._onNativeResponse (/Users/jthomassey/projects/ecom-shop-web/node_modules/follow-redirects/index.js:50:10) at Object.onceWrapper (events.js:277:13) at ClientRequest.emit (events.js:189:13) at HTTPParser.parserOnIncomingClient [as onIncoming] (_http_client.js:556:21) at HTTPParser.parserOnHeadersComplete (_http_common.js:109:17) at Socket.socketOnData (_http_client.js:442:20) ``` This can be tested here : ``` const http = require('http'); const https = require('https'); const axios = require('axios'); axios.get('http://www.photobox.fr', { httpAgent: http.Agent({ keepAlive:true }), httpsAgent: https.Agent({ keepAlive:true }) }) .then(response => { console.log(response); console.log(response.headers); }) .catch(error => { console.log(error); }); ``` Axios delegate the redirection to the follow-redirect package which accept an option `agents` for both http and https agent see : https://github.com/follow-redirects/follow-redirects#per-request-options
mhassan1
reviewed
Nov 13, 2019
@@ -85,6 +85,10 @@ module.exports = function httpAdapter(config) { | |||
method: config.method.toUpperCase(), | |||
headers: headers, | |||
agent: agent, | |||
agents: { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@JitixPhotobox i see in the follow-redirects
documentation that the object should be:
agents: {
https: Agent,
http: Agent
}
Or am I missing something?
This was referenced Jan 7, 2020
This was referenced Apr 3, 2020
Closed
This was referenced Apr 13, 2020
This was referenced Apr 21, 2020
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When calling an HTTP resource redirecting to a HTTPS one with a keepAlive agent. We get the following error:
This can be tested here :
Axios delegate the redirection to the follow-redirect package which accept an option
agents
for both http and https agent see : https://github.com/follow-redirects/follow-redirects#per-request-options