NetworkModule
大约 2 分钟
NetworkModule
HTTP请求模块
requestGet方法
发送HTTP GET请求
参数
参数 | 描述 | 类型 |
---|---|---|
url 必需 | 请求url | String |
param 必需 | 请求参数 | JSONObject |
responseCallback 必需 | 请求回调闭包 | NMAllResponse |
requestPost方法
发送HTTP POST请求
参数
参数 | 描述 | 类型 |
---|---|---|
url 必需 | 请求url | String |
param 必需 | 请求参数 | JSONObject |
responseCallback 必需 | 请求回调闭包 | NMAllResponse |
httpRequest方法
发送HTTP通用请求方法
参数
参数 | 描述 | 类型 |
---|---|---|
url 必需 | 请求url | String |
isPost 必需 | 是否为POST请求 | Boolean |
param 必需 | 请求参数 | JSONObject |
headers 非必需 | 请求头参数 | JSONObject |
cookie 非必需 | 请求cookie | String |
timeout 非必需 | 请求超时时间, 单位为秒 | Int |
responseCallback 必需 | 请求回调闭包 | NMAllResponse |
requestGetBinary方法
发送二进制HTTP GET请求
参数
参数 | 描述 | 类型 |
---|---|---|
url 必需 | 请求url | String |
param 必需 | 请求参数 | JSONObject |
responseCallback 必需 | 请求回调闭包 | NMDataResponse |
requestPostBinary方法
发送二进制HTTP POST请求
参数
参数 | 描述 | 类型 |
---|---|---|
url 必需 | 请求url | String |
bytes 必需 | 请求参数 | ByteArray |
responseCallback 必需 | 请求回调闭包 | NMDataResponse |
httpRequestBinary方法
发送二进制HTTP通用请求方法
参数
参数 | 描述 | 类型 |
---|---|---|
url 必需 | 请求url | String |
isPost 必需 | 是否为POST请求 | Boolean |
bytes 必需 | 请求参数 | ByteArray |
param 非必需 | 请求参数 | JSONObject |
headers 非必需 | 请求头参数 | JSONObject |
cookie 非必需 | 请求cookie | String |
timeout 非必需 | 请求超时时间, 单位为秒 | Int |
responseCallback 必需 | 请求回调闭包 | NMDataResponse |
类型说明
NMAllResponse
NMAllResponse = (data: JSONObject, success : Boolean , errorMsg: String, response: NetworkResponse) -> Unit
参数 | 描述 | 类型 |
---|---|---|
data | 返回数据 | JSONObject |
success | 请求是否成功 | Boolean |
errorMsg | 错误信息 | String |
response | 响应包信息 | NetworkResponse |
NMDataResponse
NMDataResponse = (data: ByteArray, success: Boolean, errorMsg: String, response: NetworkResponse) -> Unit
参数 | 描述 | 类型 |
---|---|---|
data | 返回数据 | ByteArray |
success | 请求是否成功 | Boolean |
errorMsg | 错误信息 | String |
response | 响应包信息 | NetworkResponse |
NetworkResponse
参数 | 描述 | 类型 |
---|---|---|
headerFields | 响应头参数 | JSONObject |
statusCode 非必需 | 响应状态码 | Int |