File tree Expand file tree Collapse file tree 1 file changed +19
-5
lines changed Expand file tree Collapse file tree 1 file changed +19
-5
lines changed Original file line number Diff line number Diff line change @@ -41,11 +41,25 @@ export async function httpsGetSilently(options: https.RequestOptions): Promise<s
41
41
let data : string = '' ;
42
42
https
43
43
. get ( opts , ( res ) => {
44
- res . on ( 'data' , ( d ) => ( data += d ) ) ;
45
- res . on ( 'error' , reject ) ;
46
- res . on ( 'close' , ( ) => {
47
- resolve ( data ) ;
48
- } ) ;
44
+ if ( res . statusCode === 301 || res . statusCode === 302 ) {
45
+ if ( ! res . headers . location ) {
46
+ console . error ( '301/302 without a location header' ) ;
47
+ return ;
48
+ }
49
+ https . get ( res . headers . location , ( resAfterRedirect ) => {
50
+ resAfterRedirect . on ( 'data' , ( d ) => ( data += d ) ) ;
51
+ resAfterRedirect . on ( 'error' , reject ) ;
52
+ resAfterRedirect . on ( 'close' , ( ) => {
53
+ resolve ( data ) ;
54
+ } ) ;
55
+ } ) ;
56
+ } else {
57
+ res . on ( 'data' , ( d ) => ( data += d ) ) ;
58
+ res . on ( 'error' , reject ) ;
59
+ res . on ( 'close' , ( ) => {
60
+ resolve ( data ) ;
61
+ } ) ;
62
+ }
49
63
} )
50
64
. on ( 'error' , reject ) ;
51
65
} ) ;
You can’t perform that action at this time.
0 commit comments