-
Notifications
You must be signed in to change notification settings - Fork 1
URLEncoding
Creates a url-encoded query string to be set as or appended to any existing URL query string or set as the HTTP body of the URL request. Whether the query string is set or appended to any existing URL query string or set as the HTTP body depends on the destination of the encoding.
public struct URLEncoding: ParameterEncoding
The Content-Type
HTTP header field of an encoded request with HTTP body is set to
application/x-www-form-urlencoded; charset=utf-8
.
There is no published specification for how to encode collection types. By default the convention of appending
[]
to the key for array values (foo[]=1&foo[]=2
), and appending the key surrounded by square brackets for
nested dictionary values (foo[bar]=baz
) is used. Optionally, ArrayEncoding
can be used to omit the
square brackets appended to array keys.
BoolEncoding
can be used to configure how boolean values are encoded. The default behavior is to encode
true
as 1 and false
as 0.
Creates an instance using the specified parameters.
public init(destination: Destination = .methodDependent, arrayEncoding: ArrayEncoding = .brackets, boolEncoding: BoolEncoding = .numeric)
- destination:
Destination
defining where the encoded query string will be applied..methodDependent
by default. - arrayEncoding:
ArrayEncoding
to use..brackets
by default. - boolEncoding:
BoolEncoding
to use..numeric
by default.
Returns a default URLEncoding
instance with a .methodDependent
destination.
var `default`: URLEncoding
Returns a URLEncoding
instance with a .queryString
destination.
var queryString: URLEncoding
Returns a URLEncoding
instance with an .httpBody
destination.
var httpBody: URLEncoding
The destination defining where the encoded query string is to be applied to the URL request.
let destination: Destination
The encoding to use for Array
parameters.
let arrayEncoding: ArrayEncoding
The encoding to use for Bool
parameters.
let boolEncoding: BoolEncoding
public func encode(_ urlRequest: URLRequestConvertible, with parameters: Parameters?) throws -> URLRequest
Creates a percent-escaped, URL encoded query string components from the given key-value pair recursively.
public func queryComponents(fromKey key: String, value: Any) -> [(String, String)]
- key: Key of the query component.
- value: Value of the query component.
The percent-escaped, URL encoded query string components.
Creates a percent-escaped string following RFC 3986 for a query string key or value.
public func escape(_ string: String) -> String
- string:
String
to be percent-escaped.
The percent-escaped String
.
Generated at 2020-09-24T22:11:06+0000 using swift-doc 1.0.0-beta.4.
Types
- AF
- AFError
- AFError.MultipartEncodingFailureReason
- AFError.ParameterEncoderFailureReason
- AFError.ParameterEncoderFailureReason.RequiredComponent
- AFError.ParameterEncodingFailureReason
- AFError.ResponseSerializationFailureReason
- AFError.ResponseValidationFailureReason
- AFError.ServerTrustFailureReason
- AFError.ServerTrustFailureReason.Output
- AFError.URLRequestValidationFailureReason
- Adapter
- AlamofireExtension
- AlamofireNotifications
- ClosureEventMonitor
- CompositeEventMonitor
- CompositeTrustEvaluator
- ConnectionLostRetryPolicy
- DataRequest
- DataResponse
- DataResponseSerializer
- DecodableResponseSerializer
- DefaultTrustEvaluator
- DisabledEvaluator
- DownloadRequest
- DownloadRequest.Downloadable
- DownloadRequest.Options
- DownloadResponse
- Empty
- GoogleXSSIPreprocessor
- HTTPHeader
- HTTPHeaders
- HTTPMethod
- Interceptor
- JSONEncoding
- JSONParameterEncoder
- JSONResponseSerializer
- MultipartFormData
- NetworkReachabilityManager
- NetworkReachabilityManager.NetworkReachabilityStatus
- NetworkReachabilityManager.NetworkReachabilityStatus.ConnectionType
- PassthroughPreprocessor
- PinnedCertificatesTrustEvaluator
- PublicKeysTrustEvaluator
- Redirector
- Redirector.Behavior
- Request
- Request.State
- ResponseCacher
- ResponseCacher.Behavior
- Retrier
- RetryPolicy
- RetryResult
- RevocationTrustEvaluator
- RevocationTrustEvaluator.Options
- ServerTrustManager
- Session
- SessionDelegate
- StringResponseSerializer
- URLEncodedFormEncoder
- URLEncodedFormEncoder.ArrayEncoding
- URLEncodedFormEncoder.BoolEncoding
- URLEncodedFormEncoder.DataEncoding
- URLEncodedFormEncoder.DateEncoding
- URLEncodedFormEncoder.Error
- URLEncodedFormEncoder.KeyEncoding
- URLEncodedFormEncoder.SpaceEncoding
- URLEncodedFormParameterEncoder
- URLEncodedFormParameterEncoder.Destination
- URLEncoding
- URLEncoding.ArrayEncoding
- URLEncoding.BoolEncoding
- URLEncoding.Destination
- UploadRequest
- UploadRequest.Uploadable
Protocols
- AlamofireExtended
- CachedResponseHandler
- DataDecoder
- DataPreprocessor
- DataResponseSerializerProtocol
- DownloadResponseSerializerProtocol
- EmptyResponse
- EventMonitor
- ParameterEncoder
- ParameterEncoding
- RedirectHandler
- RequestAdapter
- RequestDelegate
- RequestInterceptor
- RequestRetrier
- ResponseSerializer
- ServerTrustEvaluating
- URLConvertible
- URLRequestConvertible
- UploadConvertible
- UploadableConvertible