File tree 2 files changed +10
-2
lines changed
2 files changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -6,10 +6,12 @@ import type { FileInfo } from "../types/index.js";
6
6
export const sendRequest = async ( {
7
7
init,
8
8
redirects = [ ] ,
9
+ timeout = 60_000 ,
9
10
url,
10
11
} : {
11
12
init ?: RequestInit ;
12
13
redirects ?: string [ ] ;
14
+ timeout ?: number ;
13
15
url : URL | string ;
14
16
} ) : Promise < {
15
17
response : Response ;
@@ -21,14 +23,19 @@ export const sendRequest = async ({
21
23
const controller = new AbortController ( ) ;
22
24
const timeoutId = setTimeout ( ( ) => {
23
25
controller . abort ( ) ;
24
- } , 60_000 ) ;
26
+ } , timeout ) ;
25
27
const response = await fetch ( url , {
26
28
signal : controller . signal ,
27
29
...init ,
28
30
} ) ;
29
31
clearTimeout ( timeoutId ) ;
30
32
31
33
if ( response . status >= 400 ) {
34
+ // gracefully handle HEAD method not allowed
35
+ if ( response . status === 405 && init ?. method === 'HEAD' ) {
36
+ return { response } ;
37
+ }
38
+
32
39
throw ono ( { status : response . status } , `HTTP ERROR ${ response . status } ` ) ;
33
40
}
34
41
@@ -49,6 +56,7 @@ export const sendRequest = async ({
49
56
return sendRequest ( {
50
57
init,
51
58
redirects,
59
+ timeout,
52
60
url : resolve ( url . href , response . headers . location as string ) ,
53
61
} ) ;
54
62
}
Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " @hey-api/json-schema-ref-parser" ,
3
- "version" : " 0.0.2 " ,
3
+ "version" : " 0.0.3 " ,
4
4
"description" : " Parse, Resolve, and Dereference JSON Schema $ref pointers" ,
5
5
"homepage" : " https://heyapi.dev/" ,
6
6
"repository" : {
You can’t perform that action at this time.
0 commit comments