# HttpRequest | oops-framework
Documentation for oops-framework

# Class HttpRequest

HTTP请求

#### Hierarchy

- HttpRequest

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

#####
Index

### Constructors

constructor

### Properties

server
timeout

### Methods

abort
deleteCache
get
getByArraybuffer
getParamString
getWithParams
getWithParamsByArraybuffer
post
sendRequest

## Constructors

### constructor

- new HttpRequest(): HttpRequest

- #### Returns HttpRequest

## Properties

### server

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

服务器地址

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

### timeout

timeout: number = 10000

请求超时时间

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

## Methods

### abort

- abort(name: string): void

- 取消请求中的请求

  #### Parameters

  - ##### name: string

  #### Returns void

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

### `Private` deleteCache

- deleteCache(url: string): void

- #### Parameters

  - ##### url: string

  #### Returns void

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

### get

- get(name: string, completeCallback: Function, errorCallback: Function): void

- HTTP GET请求

  ### Example

      var complete = function(response){
         console.log(response);
      }
      var error = function(response){
         console.log(response);
      }
      oops.http.get(name, complete, error);

  #### Parameters

  - ##### name: string

    协议名

  - ##### completeCallback: Function

    请求完整回调方法

  - ##### errorCallback: Function

    请求失败回调方法

  #### Returns void

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

### getByArraybuffer

- getByArraybuffer(name: string, completeCallback: Function, errorCallback: Function): void

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

  #### Parameters

  - ##### name: string

    协议名

  - ##### completeCallback: Function

    请求完整回调方法

  - ##### errorCallback: Function

    请求失败回调方法

  #### Returns void

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

### `Private` getParamString

- getParamString(params: any): string

- 获得字符串形式的参数

  #### Parameters

  - ##### params: any

  #### Returns string

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

### getWithParams

- getWithParams(name: string, params: any, completeCallback: Function, errorCallback: Function): void

- HTTP GET请求

  ### Example

      var param = '{"uid":12345}'
      var complete = function(response){
         var jsonData = JSON.parse(response);
         var data = JSON.parse(jsonData.Data);
         console.log(data.Id);
      }
      var error = function(response){
         console.log(response);
      }
      oops.http.getWithParams(name, param, complete, error);

  #### Parameters

  - ##### name: string

    协议名

  - ##### params: any

    查询参数

  - ##### completeCallback: Function

    请求完整回调方法

  - ##### errorCallback: Function

    请求失败回调方法

  #### Returns void

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

### getWithParamsByArraybuffer

- getWithParamsByArraybuffer(name: string, params: any, completeCallback: Function, errorCallback: Function): void

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

  #### Parameters

  - ##### name: string

    协议名

  - ##### params: any

    查询参数

  - ##### completeCallback: Function

    请求完整回调方法

  - ##### errorCallback: Function

    请求失败回调方法

  #### Returns void

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

### post

- post(name: string, params: any, completeCallback?: Function, errorCallback?: Function): void

- HTTP POST请求

  ### Example

      var param = '{"LoginCode":"donggang_dev","Password":"e10adc3949ba59abbe56e057f20f883e"}'
      var complete = function(response){
         var jsonData = JSON.parse(response);
         var data = JSON.parse(jsonData.Data);
         console.log(data.Id);
      }
      var error = function(response){
         console.log(response);
      }
      oops.http.post(name, param, complete, error);

  #### Parameters

  - ##### name: string

    协议名

  - ##### params: any

    查询参数

  - ##### `Optional` completeCallback: Function

    请求完整回调方法

  - ##### `Optional` errorCallback: Function

    请求失败回调方法

  #### Returns void

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

### `Private` sendRequest

- sendRequest(name: string, params: any, isPost: boolean, completeCallback?: Function, errorCallback?: Function, responseType?: string, isOpenTimeout?: boolean, timeout?: number): void

- Http请求

  #### Parameters

  - ##### name: string

  - ##### params: any

  - ##### isPost: boolean

  - ##### `Optional` completeCallback: Function

  - ##### `Optional` errorCallback: Function

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

  - ##### isOpenTimeout: boolean = true

  - ##### timeout: number = ...

  #### Returns void

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

Generated using TypeDoc