File tree 4 files changed +55
-16
lines changed
4 files changed +55
-16
lines changed Original file line number Diff line number Diff line change @@ -13,9 +13,7 @@ type BundlerDoctor struct {
13
13
}
14
14
15
15
func NewBundlerDoctor () * BundlerDoctor {
16
- t := http .DefaultTransport .(* http.Transport ).Clone ()
17
- t .MaxIdleConnsPerHost = - 1
18
- client := & http.Client {Transport : t }
16
+ client := & http.Client {}
19
17
return & BundlerDoctor {HTTPClient : * client }
20
18
}
21
19
Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ package cmd
2
2
3
3
import (
4
4
"encoding/json"
5
+ "errors"
5
6
"fmt"
6
7
"io"
7
8
"net/http"
@@ -22,13 +23,26 @@ type Nodejs struct {
22
23
23
24
func (n * Nodejs ) fetchURLFromRegistry (client http.Client ) (string , error ) {
24
25
url := fmt .Sprintf (NODEJS_REGISTRY_API , n .name )
25
- req , _ := http .NewRequest (http .MethodGet , url , nil )
26
- resp , _ := client .Do (req )
27
- body , _ := io .ReadAll (resp .Body )
26
+ req , err := http .NewRequest (http .MethodGet , url , nil )
27
+ if err != nil {
28
+ return "" , err
29
+ }
30
+
31
+ resp , err := client .Do (req )
32
+ if err != nil {
33
+ return "" , nil
34
+ }
35
+
28
36
defer resp .Body .Close ()
37
+ if resp .StatusCode < 200 || 299 < resp .StatusCode {
38
+ m := fmt .Sprintf ("Got status code: %d from %s" , resp .StatusCode , RUBY_GEMS_REGISTRY_API )
39
+ return "" , errors .New (m )
40
+ }
41
+
42
+ body , _ := io .ReadAll (resp .Body )
29
43
30
44
var NodejsRegistryResponse NodejsRegistryResponse
31
- err : = json .Unmarshal (body , & NodejsRegistryResponse )
45
+ err = json .Unmarshal (body , & NodejsRegistryResponse )
32
46
if err != nil {
33
47
return "" , nil
34
48
}
Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ package cmd
2
2
3
3
import (
4
4
"encoding/json"
5
+ "errors"
5
6
"fmt"
6
7
"io"
7
8
"net/http"
@@ -25,13 +26,26 @@ type Pypi struct {
25
26
26
27
func (p * Pypi ) fetchURLFromRepository (client http.Client ) (string , error ) {
27
28
url := fmt .Sprintf (PYPI_REGISTRY_API , p .name )
28
- req , _ := http .NewRequest (http .MethodGet , url , nil )
29
- resp , _ := client .Do (req )
30
- body , _ := io .ReadAll (resp .Body )
29
+ req , err := http .NewRequest (http .MethodGet , url , nil )
30
+ if err != nil {
31
+ return "" , err
32
+ }
33
+
34
+ resp , err := client .Do (req )
35
+ if err != nil {
36
+ return "" , err
37
+ }
38
+
31
39
defer resp .Body .Close ()
40
+ if resp .StatusCode < 200 || 299 < resp .StatusCode {
41
+ m := fmt .Sprintf ("Got status code: %d from %s" , resp .StatusCode , RUBY_GEMS_REGISTRY_API )
42
+ return "" , errors .New (m )
43
+ }
44
+
45
+ body , _ := io .ReadAll (resp .Body )
32
46
33
47
var PypiRegistryResponse PypiRegistryResponse
34
- err : = json .Unmarshal (body , & PypiRegistryResponse )
48
+ err = json .Unmarshal (body , & PypiRegistryResponse )
35
49
if err != nil {
36
50
return "" , nil
37
51
}
Original file line number Diff line number Diff line change @@ -23,15 +23,28 @@ type RubyGems struct {
23
23
24
24
func (g * RubyGems ) fetchURLFromRegistry (client http.Client ) (string , error ) {
25
25
url := fmt .Sprintf (RUBY_GEMS_REGISTRY_API , g .name )
26
- req , _ := http .NewRequest (http .MethodGet , url , nil )
27
- resp , _ := client .Do (req )
28
- body , _ := io .ReadAll (resp .Body )
26
+ req , err := http .NewRequest (http .MethodGet , url , nil )
27
+ if err != nil {
28
+ return "" , err
29
+ }
30
+
31
+ resp , err := client .Do (req )
32
+ if err != nil {
33
+ return "" , err
34
+ }
35
+
29
36
defer resp .Body .Close ()
37
+ if resp .StatusCode < 200 || 299 < resp .StatusCode {
38
+ m := fmt .Sprintf ("Got status code: %d from %s" , resp .StatusCode , RUBY_GEMS_REGISTRY_API )
39
+ return "" , errors .New (m )
40
+ }
41
+
42
+ body , _ := io .ReadAll (resp .Body )
30
43
31
44
var Gem RubyGemsRegistryResponse
32
- err : = json .Unmarshal (body , & Gem )
45
+ err = json .Unmarshal (body , & Gem )
33
46
if err != nil {
34
- return "" , errors . New ( "error: Unknown response" )
47
+ return "" , err
35
48
}
36
49
37
50
if Gem .SourceCodeUri != "" {
You can’t perform that action at this time.
0 commit comments