Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x | import { BrowserNet } from './BrowserNet'
import { ServerNet } from './ServerNet'
function toLowerHeader(headers) {
let newHeaders = {}
for (var id in headers) {
let lowerId = id.toLowerCase()
newHeaders[lowerId] = headers[id]
}
return newHeaders
}
export class Net {
//default timeout
static timeout = 3 * 60 * 1000
static httpGet(url: string, params: any, config?: any) {
if (config && config.headers) {
config.headers = toLowerHeader(config.headers)
}
let _process = process as any
if (!_process.browser) {
return ServerNet.httpGet(url, params, null, config)
} else {
if (config && config.headers) {
//remove unsafe header,should be added in browser
delete config.headers['accept-encoding']
}
return BrowserNet.httpGet(url, params, null, config)
}
}
static httpPost(url: string, params: any, config?: any) {
if (config && config.headers) {
config.headers = toLowerHeader(config.headers)
}
let _process = process as any
if (!_process.browser) {
return ServerNet.httpPost(url, params, null, config)
} else {
if (config && config.headers) {
delete config.headers['accept-encoding']
}
return BrowserNet.httpPost(url, params, null, config)
}
}
}
|