# Class HttpRequest

HTTP请求

#### Hierarchy

- HttpRequest

- Defined in assets/libs/network/HttpRequest.ts:39

#####
Index

### Constructors

constructor

### Properties

header
server
timeout

### Methods

abort
addHeader
deleteCache
get
getAsync
getAsyncByArraybuffer
getByArraybuffer
getParamString
post
postAsync
sendRequest

## Constructors

### constructor

- new HttpRequest(): HttpRequest

- #### Returns HttpRequest

## Properties

### `Private` header

header: Map<string, string> = ...

自定义请求头信息

- Defined in assets/libs/network/HttpRequest.ts:45

### server

server: string = "http://127.0.0.1/"

服务器地址

- Defined in assets/libs/network/HttpRequest.ts:41

### timeout

timeout: number = 10000

请求超时时间

- Defined in assets/libs/network/HttpRequest.ts:43

## Methods

### abort

- abort(name: string): void

- 取消请求中的请求

  #### Parameters

  - ##### name: string

    协议名

  #### Returns void

  - Defined in assets/libs/network/HttpRequest.ts:147

### addHeader

- addHeader(name: string, value: string): void

- 添加自定义请求头信息

  #### Parameters

  - ##### name: string

    信息名

  - ##### value: string

    信息值

  #### Returns void

  - Defined in assets/libs/network/HttpRequest.ts:52

### `Private` deleteCache

- deleteCache(url: string): void

- #### Parameters

  - ##### url: string

  #### Returns void

  - Defined in assets/libs/network/HttpRequest.ts:308

### get

- get(name: string, onComplete: HttpCallback, params?: any): void

- HTTP GET请求

  ### Example

      var param = '{"uid":12345}'
      var complete = (ret: HttpReturn) => {
         console.log(ret.res);
      }
      oops.http.getWithParams(name, complete, param);

  #### Parameters

  - ##### name: string

    协议名

  - ##### onComplete: HttpCallback

    请求完整回调方法

  - ##### params: any = null

    查询参数

  #### Returns void

  - Defined in assets/libs/network/HttpRequest.ts:68

### getAsync

- getAsync(name: string, params?: any): Promise< HttpReturn >

- HTTP GET请求

  ### Example

      var txt = await oops.http.getAsync(name);
      if (txt.isSucc) {
         console.log(txt.res);
      }

  #### Parameters

  - ##### name: string

    协议名

  - ##### params: any = null

    查询参数

  #### Returns Promise< HttpReturn >

  - Defined in assets/libs/network/HttpRequest.ts:82

### getAsyncByArraybuffer

- getAsyncByArraybuffer(name: string, params?: any): Promise< HttpReturn >

- HTTP GET请求非文本格式数据

  ### Returns

  Promise<any>

  #### Parameters

  - ##### name: string

    协议名

  - ##### params: any = null

    查询参数

  #### Returns Promise< HttpReturn >

  - Defined in assets/libs/network/HttpRequest.ts:106

### getByArraybuffer

- getByArraybuffer(name: string, onComplete: HttpCallback, params?: any): void

- HTTP GET请求非文本格式数据

  #### Parameters

  - ##### name: string

    协议名

  - ##### onComplete: HttpCallback

    请求完整回调方法

  - ##### params: any = null

    查询参数

  #### Returns void

  - Defined in assets/libs/network/HttpRequest.ts:96

### `Private` getParamString

- getParamString(params: any): string

- 获得字符串形式的参数

  ### Returns

  参数字符串

  #### Parameters

  - ##### params: any

    参数对象

  #### Returns string

  - Defined in assets/libs/network/HttpRequest.ts:159

### post

- post(name: string, onComplete: HttpCallback, params?: any): void

- HTTP POST请求

  ### Example

      var param = '{"LoginCode":"donggang_dev","Password":"e10adc3949ba59abbe56e057f20f883e"}'
      var complete = (ret: HttpReturn) => {
         console.log(ret.res);
      }
      oops.http.post(name, complete, param);

  #### Parameters

  - ##### name: string

    协议名

  - ##### onComplete: HttpCallback

    请求完整回调方法

  - ##### params: any = null

    查询参数

  #### Returns void

  - Defined in assets/libs/network/HttpRequest.ts:126

### postAsync

- postAsync(name: string, params?: any): Promise< HttpReturn >

- HTTP POST请求

  #### Parameters

  - ##### name: string

    协议名

  - ##### params: any = null

    查询参数

  #### Returns Promise< HttpReturn >

  - Defined in assets/libs/network/HttpRequest.ts:135

### `Private` sendRequest

- sendRequest(name: string, params: any, isPost: boolean, onComplete: HttpCallback, responseType?: string, isOpenTimeout?: boolean): void

- Http请求

  #### Parameters

  - ##### name: string

  - ##### params: any

  - ##### isPost: boolean

  - ##### onComplete: HttpCallback

  - ##### `Optional` responseType: string

  - ##### isOpenTimeout: boolean = true

  #### Returns void

  - Defined in assets/libs/network/HttpRequest.ts:183

Generated using TypeDoc