@@ -63,19 +63,14 @@ export abstract class HttpExecutor<REQUEST_OPTS, REQUEST> {
6363 protected readonly debug = _debug ( "electron-builder" )
6464
6565 request < T > ( options : RequestOptions , data ?: { [ name : string ] : any ; } | null ) : Promise < T > {
66- options = Object . assign ( { headers : { "User-Agent" : "electron-builder" } } , options )
67-
66+ configureRequestOptions ( options )
6867 const encodedData = data == null ? undefined : new Buffer ( JSON . stringify ( data ) )
6968 if ( encodedData != null ) {
7069 options . method = "post"
71- if ( options . headers == null ) {
72- options . headers = { }
73- }
74-
75- options . headers [ "Content-Type" ] = "application/json"
76- options . headers [ "Content-Length" ] = encodedData . length
70+ options . headers ! [ "Content-Type" ] = "application/json"
71+ options . headers ! [ "Content-Length" ] = encodedData . length
7772 }
78- return this . doApiRequest < T > ( < any > options , it => ( < any > it ) . end ( encodedData ) , 0 )
73+ return this . doApiRequest < T > ( < REQUEST_OPTS > options , it => ( < any > it ) . end ( encodedData ) , 0 )
7974 }
8075
8176 protected abstract doApiRequest < T > ( options : REQUEST_OPTS , requestProcessor : ( request : REQUEST , reject : ( error : Error ) => void ) => void , redirectCount : number ) : Promise < T >
@@ -270,7 +265,7 @@ function configurePipes(options: DownloadOptions, response: any, destination: st
270265 fileOut . on ( "finish" , ( ) => ( < any > fileOut . close ) ( callback ) )
271266}
272267
273- export function configureRequestOptions ( options : RequestOptions , token : string | null , method ?: string ) : RequestOptions {
268+ export function configureRequestOptions ( options : RequestOptions , token ? : string | null , method ?: "GET" | "DELETE" | "PUT" ) : RequestOptions {
274269 if ( method != null ) {
275270 options . method = method
276271 }
@@ -286,6 +281,10 @@ export function configureRequestOptions(options: RequestOptions, token: string |
286281 if ( headers [ "User-Agent" ] == null ) {
287282 headers [ "User-Agent" ] = "electron-builder"
288283 }
284+
285+ if ( ( method == null || method === "GET" ) || headers [ "Cache-Control" ] == null ) {
286+ headers [ "Cache-Control" ] = "no-cache"
287+ }
289288 return options
290289}
291290
0 commit comments