mirror of
https://github.com/actions/http-client.git
synced 2025-04-22 02:02:29 +00:00
Merge 98a80ecfc5
into 602cbafdf5
This commit is contained in:
commit
92248290af
@ -62,6 +62,21 @@ describe('basics', () => {
|
||||
done()
|
||||
})
|
||||
|
||||
it('does basic http get request with overridden user agent', async done => {
|
||||
let res: httpm.HttpClientResponse = await _http.get(
|
||||
'http://httpbin.org/get',
|
||||
{
|
||||
'user-agent': 'custom-user-agent'
|
||||
}
|
||||
)
|
||||
expect(res.message.statusCode).toBe(200)
|
||||
let body: string = await res.readBody()
|
||||
let obj: any = JSON.parse(body)
|
||||
expect(obj.url).toBe('http://httpbin.org/get')
|
||||
expect(obj.headers['User-Agent']).toBe('custom-user-agent')
|
||||
done()
|
||||
})
|
||||
|
||||
it('does basic https get request', async done => {
|
||||
let res: httpm.HttpClientResponse = await _http.get(
|
||||
'https://httpbin.org/get'
|
||||
|
2
index.ts
2
index.ts
@ -562,7 +562,7 @@ export class HttpClient {
|
||||
(info.parsedUrl.pathname || '') + (info.parsedUrl.search || '')
|
||||
info.options.method = method
|
||||
info.options.headers = this._mergeHeaders(headers)
|
||||
if (this.userAgent != null) {
|
||||
if (this.userAgent != null && !('user-agent' in info.options.headers)) {
|
||||
info.options.headers['user-agent'] = this.userAgent
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user