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

fix: if scheme is http:// use an HTTP agent #75

Merged
merged 6 commits into from
Aug 13, 2019
Merged

fix: if scheme is http:// use an HTTP agent #75

merged 6 commits into from
Aug 13, 2019

Conversation

bcoe
Copy link
Contributor

@bcoe bcoe commented Aug 9, 2019

we were always creating an https.Agent, even though we accept an http:// scheme.

@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Aug 9, 2019
Copy link
Member

@jeanbza jeanbza left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM but not a node expert heh. :)

src/index.ts Outdated Show resolved Hide resolved
@codecov
Copy link

codecov bot commented Aug 12, 2019

Codecov Report

Merging #75 into master will increase coverage by 0.63%.
The diff coverage is 94.11%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #75      +/-   ##
==========================================
+ Coverage   69.55%   70.18%   +0.63%     
==========================================
  Files           1        1              
  Lines         358      369      +11     
  Branches       32       36       +4     
==========================================
+ Hits          249      259      +10     
- Misses        108      109       +1     
  Partials        1        1
Impacted Files Coverage Δ
src/index.ts 70.18% <94.11%> (+0.63%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f6db420...2b15ff3. Read the comment docs.

src/index.ts Outdated Show resolved Hide resolved
test/index.ts Outdated Show resolved Hide resolved
src/index.ts Outdated Show resolved Hide resolved
test/index.ts Show resolved Hide resolved
src/index.ts Outdated
@@ -80,6 +82,8 @@ export interface RequestCallback<T = any> {
(err: Error | null, response: Response, body?: T): void;
}

// tslint:disable-next-line variable-name
const HttpProxyAgent = require('http-proxy-agent');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For both of these ... I think we should delay the require. For 90%+ of cases here, I'd guess folks aren't using proxies. For those cases, I would prefer to lazy load the module required.

src/index.ts Outdated
@@ -130,15 +134,21 @@ function requestToFetchOptions(reqOpts: Options) {
uri = uri + '?' + params;
}

const isHttp = /^http:\/\//.test(uri);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a total nit, and calls out how lame of a programmer I am. Instead of using a regex - could we just say:

const isHttp = uri.startsWith('http://');

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you're right, I still use contains and regexes more than I think I need to, since I haven't done as well updating my brain to reflect JavaScript's API improvements.

@bcoe
Copy link
Contributor Author

bcoe commented Aug 13, 2019

@callmehiphop @JustinBeckwith okay, addressed additional review and added test for HTTP proxy.

src/index.ts Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes This human has signed the Contributor License Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants