# BaseRequest

abstract class BaseRequest
Content copied to clipboard

## Functions

addDownloadListener
Link copied to clipboard
fun addDownloadListener(progressListener: ProgressListener)
Content copied to clipboard
下载监听器
addHeader
Link copied to clipboard
fun addHeader(name: String, value: String)
Content copied to clipboard
添加请求头 如果已存在相同`name`的请求头会添加而不会覆盖, 因为请求头本身存在多个值
buildRequest
Link copied to clipboard
open fun buildRequest(): Request
Content copied to clipboard
enqueue
Link copied to clipboard
fun enqueue(block: Callback): Call
Content copied to clipboard
队列请求.
execute
Link copied to clipboard
inline fun <R> execute(): R
Content copied to clipboard
执行同步请求
onResult
Link copied to clipboard
inline fun <R> onResult(crossinline block: Result<R>.() -> Unit): Call
Content copied to clipboard
队列请求.
param
Link copied to clipboard
abstract fun param(name: String, value: Boolean?)
Content copied to clipboard
abstract fun param(name: String, value: Number?)
Content copied to clipboard
abstract fun param(name: String, value: String?, encoded: Boolean = false)
Content copied to clipboard
removeHeader
Link copied to clipboard
fun removeHeader(name: String)
Content copied to clipboard
删除请求头
setCacheControl
Link copied to clipboard
fun setCacheControl(cacheControl: CacheControl)
Content copied to clipboard
设置请求头的缓存控制
setClient
Link copied to clipboard
fun setClient(block: OkHttpClient.Builder.() -> Unit)
Content copied to clipboard
修改当前Request的OkHttpClient配置, 不会影响全局默认的OkHttpClient
setDownloadDir
Link copied to clipboard
fun setDownloadDir(name: File?)
Content copied to clipboard
fun setDownloadDir(name: String?)
Content copied to clipboard
下载文件的保存目录
setDownloadFileName
Link copied to clipboard
fun setDownloadFileName(name: String?)
Content copied to clipboard
下载文件名
setDownloadFileNameConflict
Link copied to clipboard
fun setDownloadFileNameConflict(enabled: Boolean = true)
Content copied to clipboard
假设下载文件路径已存在同名文件是否重命名, 例如`file_name(1).apk`
setDownloadFileNameDecode
Link copied to clipboard
fun setDownloadFileNameDecode(enabled: Boolean = true)
Content copied to clipboard
文件名称是否使用URL解码 例如下载的文件名如果是中文, 服务器传输给你的会是被URL编码的字符串.
setDownloadMd5Verify
Link copied to clipboard
fun setDownloadMd5Verify(enabled: Boolean = true)
Content copied to clipboard
如果服务器返回 "Content-MD5"响应头和制定路径已经存在的文件MD5相同是否直接返回File
setDownloadTempFile
Link copied to clipboard
fun setDownloadTempFile(enabled: Boolean = true)
Content copied to clipboard
下载是否使用临时文件 避免下载失败后覆盖同名文件或者无法判别是否已下载完整, 仅在下载完整以后才会显示为原有文件名 临时文件命名规则: 文件名 + .net-download 下载文件名: install.apk, 临时文件名: install.apk.
setGroup
Link copied to clipboard
fun setGroup(group: Any?)
Content copied to clipboard
分组
setHeader
Link copied to clipboard
fun setHeader(name: String, value: String)
Content copied to clipboard
设置请求头, 会覆盖请求头而不像addHeader是添加
setHeaders
Link copied to clipboard
fun setHeaders(headers: Headers)
Content copied to clipboard
批量设置请求头
setId
Link copied to clipboard
fun setId(id: Any?)
Content copied to clipboard
唯一的Id
setKType
Link copied to clipboard
inline fun <T> setKType()
Content copied to clipboard
为请求附着针对Kotlin的Type信息
setLogRecord
Link copied to clipboard
fun setLogRecord(enabled: Boolean)
Content copied to clipboard
是否启用日志记录器
setPath
Link copied to clipboard
fun setPath(path: String?)
Content copied to clipboard
解析配置Path, 支持识别query参数和绝对路径
setQuery
Link copied to clipboard
fun setQuery(name: String, value: String?, encoded: Boolean = false)
Content copied to clipboard
setTag
Link copied to clipboard
fun setTag(tag: Any?)
Content copied to clipboard
将一个任意对象添加到Request对象中, 一般用于在拦截器或者转换器中被获取到标签, 针对某个请求的特殊业务逻辑 使用`Request.tag()`获取标签
fun setTag(name: String, tag: Any?)
Content copied to clipboard
添加标签 使用`Request.tag(name)`得到指定标签
setUrl
Link copied to clipboard
open fun setUrl(url: URL)
Content copied to clipboard
open fun setUrl(url: HttpUrl)
Content copied to clipboard
open fun setUrl(url: String)
Content copied to clipboard
设置一个Url字符串, 其参数不会和你初始化时设置的主域名NetConfig.host进行拼接 一般情况下我建议使用更为聪明的setPath
toResult
Link copied to clipboard
inline fun <R> toResult(): Result<R>
Content copied to clipboard
执行同步请求

## Properties

converter
Link copied to clipboard
open var converter: NetConverter
Content copied to clipboard
httpUrl
Link copied to clipboard
open var httpUrl: HttpUrl.Builder
Content copied to clipboard
method
Link copied to clipboard
open var method: Method
Content copied to clipboard
okHttpClient
Link copied to clipboard
open var okHttpClient: OkHttpClient
Content copied to clipboard
okHttpRequest
Link copied to clipboard
open var okHttpRequest: Request.Builder
Content copied to clipboard
tags
Link copied to clipboard
open var tags: NetLabel.TagHashMap
Content copied to clipboard

## Inheritors

BodyRequest
Link copied to clipboard
UrlRequest
Link copied to clipboard