Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
white49
Alamofire
提交
dc836f64
A
Alamofire
项目概览
white49
/
Alamofire
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
A
Alamofire
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
dc836f64
编写于
4月 12, 2019
作者:
C
Christian Noon
提交者:
GitHub
4月 12, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Updated all Request classes to be public instead of open (#2804)
上级
9361fd2b
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
20 addition
and
20 deletion
+20
-20
Source/Request.swift
Source/Request.swift
+20
-20
未找到文件。
Source/Request.swift
浏览文件 @
dc836f64
...
...
@@ -26,7 +26,7 @@ import Foundation
/// `Request` is the common superclass of all Alamofire request types and provides common state, delegate, and callback
/// handling.
open
class
Request
{
public
class
Request
{
/// State of the `Request`, with managed transitions between states set when calling `resume()`, `suspend()`, or
/// `cancel()` on the `Request`.
///
...
...
@@ -479,7 +479,7 @@ open class Request {
///
/// - Returns: The `Request`.
@discardableResult
open
func
cancel
()
->
Self
{
public
func
cancel
()
->
Self
{
guard
protectedMutableState
.
attemptToTransitionTo
(
.
cancelled
)
else
{
return
self
}
delegate
?
.
cancelRequest
(
self
)
...
...
@@ -491,7 +491,7 @@ open class Request {
///
/// - Returns: The `Request`.
@discardableResult
open
func
suspend
()
->
Self
{
public
func
suspend
()
->
Self
{
guard
protectedMutableState
.
attemptToTransitionTo
(
.
suspended
)
else
{
return
self
}
delegate
?
.
suspendRequest
(
self
)
...
...
@@ -504,7 +504,7 @@ open class Request {
///
/// - Returns: The `Request`.
@discardableResult
open
func
resume
()
->
Self
{
public
func
resume
()
->
Self
{
guard
protectedMutableState
.
attemptToTransitionTo
(
.
resumed
)
else
{
return
self
}
delegate
?
.
resumeRequest
(
self
)
...
...
@@ -522,7 +522,7 @@ open class Request {
/// - persistence: The `URLCredential.Persistence` for the created `URLCredential`.
/// - Returns: The `Request`.
@discardableResult
open
func
authenticate
(
username
:
String
,
password
:
String
,
persistence
:
URLCredential
.
Persistence
=
.
forSession
)
->
Self
{
public
func
authenticate
(
username
:
String
,
password
:
String
,
persistence
:
URLCredential
.
Persistence
=
.
forSession
)
->
Self
{
let
credential
=
URLCredential
(
user
:
username
,
password
:
password
,
persistence
:
persistence
)
return
authenticate
(
with
:
credential
)
...
...
@@ -533,7 +533,7 @@ open class Request {
/// - Parameter credential: The `URLCredential`.
/// - Returns: The `Request`.
@discardableResult
open
func
authenticate
(
with
credential
:
URLCredential
)
->
Self
{
public
func
authenticate
(
with
credential
:
URLCredential
)
->
Self
{
protectedMutableState
.
write
{
$0
.
credential
=
credential
}
return
self
...
...
@@ -548,7 +548,7 @@ open class Request {
/// - closure: The code to be executed periodically as data is read from the server.
/// - Returns: The `Request`.
@discardableResult
open
func
downloadProgress
(
queue
:
DispatchQueue
=
.
main
,
closure
:
@escaping
ProgressHandler
)
->
Self
{
public
func
downloadProgress
(
queue
:
DispatchQueue
=
.
main
,
closure
:
@escaping
ProgressHandler
)
->
Self
{
protectedMutableState
.
write
{
$0
.
downloadProgressHandler
=
(
handler
:
closure
,
queue
:
queue
)
}
return
self
...
...
@@ -563,7 +563,7 @@ open class Request {
/// - closure: The closure to be executed periodically as data is sent to the server.
/// - Returns: The `Request`.
@discardableResult
open
func
uploadProgress
(
queue
:
DispatchQueue
=
.
main
,
closure
:
@escaping
ProgressHandler
)
->
Self
{
public
func
uploadProgress
(
queue
:
DispatchQueue
=
.
main
,
closure
:
@escaping
ProgressHandler
)
->
Self
{
protectedMutableState
.
write
{
$0
.
uploadProgressHandler
=
(
handler
:
closure
,
queue
:
queue
)
}
return
self
...
...
@@ -576,7 +576,7 @@ open class Request {
/// - Parameter handler: The `RedirectHandler`.
/// - Returns: The `Request`.
@discardableResult
open
func
redirect
(
using
handler
:
RedirectHandler
)
->
Self
{
public
func
redirect
(
using
handler
:
RedirectHandler
)
->
Self
{
protectedMutableState
.
write
{
mutableState
in
precondition
(
mutableState
.
redirectHandler
==
nil
,
"Redirect handler has already been set"
)
mutableState
.
redirectHandler
=
handler
...
...
@@ -592,7 +592,7 @@ open class Request {
/// - Parameter handler: The `CachedResponseHandler`.
/// - Returns: The `Request`.
@discardableResult
open
func
cacheResponse
(
using
handler
:
CachedResponseHandler
)
->
Self
{
public
func
cacheResponse
(
using
handler
:
CachedResponseHandler
)
->
Self
{
protectedMutableState
.
write
{
mutableState
in
precondition
(
mutableState
.
cachedResponseHandler
==
nil
,
"Cached response handler has already been set"
)
mutableState
.
cachedResponseHandler
=
handler
...
...
@@ -735,7 +735,7 @@ public protocol RequestDelegate: AnyObject {
// MARK: DataRequest
open
class
DataRequest
:
Request
{
public
class
DataRequest
:
Request
{
public
let
convertible
:
URLRequestConvertible
private
var
protectedData
:
Protector
<
Data
?
>
=
Protector
(
nil
)
...
...
@@ -818,7 +818,7 @@ open class DataRequest: Request {
}
}
open
class
DownloadRequest
:
Request
{
public
class
DownloadRequest
:
Request
{
/// A collection of options to be executed prior to moving a downloaded file from the temporary URL to the
/// destination URL.
public
struct
Options
:
OptionSet
{
...
...
@@ -857,10 +857,10 @@ open class DownloadRequest: Request {
/// - parameter domain: The search path domain mask. `.userDomainMask` by default.
///
/// - returns: A download file destination closure.
open
class
func
suggestedDownloadDestination
(
for
directory
:
FileManager
.
SearchPathDirectory
=
.
documentDirectory
,
in
domain
:
FileManager
.
SearchPathDomainMask
=
.
userDomainMask
,
options
:
Options
=
[])
->
Destination
{
return
{
(
temporaryURL
,
response
)
in
public
class
func
suggestedDownloadDestination
(
for
directory
:
FileManager
.
SearchPathDirectory
=
.
documentDirectory
,
in
domain
:
FileManager
.
SearchPathDomainMask
=
.
userDomainMask
,
options
:
Options
=
[])
->
Destination
{
return
{
temporaryURL
,
response
in
let
directoryURLs
=
FileManager
.
default
.
urls
(
for
:
directory
,
in
:
domain
)
let
url
=
directoryURLs
.
first
?
.
appendingPathComponent
(
response
.
suggestedFilename
!
)
??
temporaryURL
...
...
@@ -944,12 +944,12 @@ open class DownloadRequest: Request {
return
session
.
downloadTask
(
with
:
request
)
}
open
func
task
(
forResumeData
data
:
Data
,
using
session
:
URLSession
)
->
URLSessionTask
{
public
func
task
(
forResumeData
data
:
Data
,
using
session
:
URLSession
)
->
URLSessionTask
{
return
session
.
downloadTask
(
withResumeData
:
data
)
}
@discardableResult
open
override
func
cancel
()
->
Self
{
public
override
func
cancel
()
->
Self
{
guard
state
.
canTransitionTo
(
.
cancelled
)
else
{
return
self
}
state
=
.
cancelled
...
...
@@ -992,7 +992,7 @@ open class DownloadRequest: Request {
}
}
open
class
UploadRequest
:
DataRequest
{
public
class
UploadRequest
:
DataRequest
{
public
enum
Uploadable
{
case
data
(
Data
)
case
file
(
URL
,
shouldRemove
:
Bool
)
...
...
@@ -1065,7 +1065,7 @@ open class UploadRequest: DataRequest {
return
stream
}
open
override
func
cleanup
()
{
public
override
func
cleanup
()
{
super
.
cleanup
()
guard
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录