HttpRequest class

可支持 restful 请求和普通API请求

GET、POST、PUT、HEAD、DELETE、PATCH、DOWNLOAD
主要作用为统一处理相关事务:

  • 统一处理请求前缀;
  • 统一打印请求信息;
  • 统一打印响应信息;
  • 统一打印报错信息;

Constructors

HttpRequest()
factory

Properties

client → Dio?
no setter
hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

delete<T>(String url, {Map<String, dynamic>? params, Options? options, CancelToken? cancelToken, OnSuccess? onSuccess, OnFailed? onFailed, OnCommon? onCommon, dynamic bind}) Future
DELETE 请求
download(String url, dynamic savePath, {Map<String, dynamic>? params, Options? options, CancelToken? cancelToken, Map<String, dynamic>? queryParameters, bool deleteOnError = true, String lengthHeader = Headers.contentLengthHeader, ProgressCallback? onReceiveProgress, OnSuccess? onSuccess, OnFailed? onFailed, OnCommon? onCommon, dynamic bind}) Future
DOWNLOAD 请求
get<T>(String url, {Map<String, dynamic>? params, Options? options, CancelToken? cancelToken, ProgressCallback? onReceiveProgress, OnSuccess? onSuccess, OnFailed? onFailed, OnCommon? onCommon, dynamic bind}) Future
GET 请求
HEAD 请求
init(HttpRequestSetting setting) → void
初始化
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
patch<T>(String url, {Map<String, dynamic>? params, Options? options, CancelToken? cancelToken, ProgressCallback? onSendProgress, ProgressCallback? onReceiveProgress, OnSuccess? onSuccess, OnFailed? onFailed, OnCommon? onCommon, dynamic bind}) Future
PATCH 请求
post<T>(String url, {Map<String, dynamic>? params, Map<String, dynamic>? formData, Options? options, CancelToken? cancelToken, ProgressCallback? onSendProgress, ProgressCallback? onReceiveProgress, OnSuccess? onSuccess, OnFailed? onFailed, OnCommon? onCommon, dynamic bind}) Future
POST 请求
put<T>(String url, {Map<String, dynamic>? params, Options? options, CancelToken? cancelToken, ProgressCallback? onSendProgress, ProgressCallback? onReceiveProgress, OnSuccess? onSuccess, OnFailed? onFailed, OnCommon? onCommon, dynamic bind}) Future
PUT 请求
setupCertificateAuthorityVerification(String pem) → void
证书颁发机构验证
setupHttpsCertificateVerification(String fingerprint) → void
HTTPS证书验证

use openssl to read the SHA256 value of a certificate:
openssl s_client -servername pinning-test.badssl.com -connect pinning-test.badssl.com:443 < /dev/null 2>/dev/null \ | openssl x509 -noout -fingerprint -sha256
setupProxy(String host, int port) → void
设置代理(不支持Web)
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited