-
Notifications
You must be signed in to change notification settings - Fork 1
URLEncodedFormEncoder
An object that encodes instances into URL-encoded query strings.
public final class URLEncodedFormEncoder
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 Bool
values are encoded. The default behavior is to encode
true
as 1 and false
as 0.
DateEncoding
can be used to configure how Date
values are encoded. By default, the .deferredToDate
strategy is used, which formats dates from their structure.
SpaceEncoding
can be used to configure how spaces are encoded. Modern encodings use percent replacement (%20
),
while older encodings may expect spaces to be replaced with +
.
This type is largely based on Vapor's url-encoded-form
project.
init(alphabetizeKeyValuePairs:arrayEncoding:boolEncoding:dataEncoding:dateEncoding:keyEncoding:spaceEncoding:allowedCharacters:)
Creates an instance from the supplied parameters.
public init(alphabetizeKeyValuePairs: Bool = true, arrayEncoding: ArrayEncoding = .brackets, boolEncoding: BoolEncoding = .numeric, dataEncoding: DataEncoding = .base64, dateEncoding: DateEncoding = .deferredToDate, keyEncoding: KeyEncoding = .useDefaultKeys, spaceEncoding: SpaceEncoding = .percentEscaped, allowedCharacters: CharacterSet = .afURLQueryAllowed)
- alphabetizeKeyValuePairs: Whether or not to sort the encoded key value pairs.
true
by default. - arrayEncoding: The
ArrayEncoding
to use..brackets
by default. - boolEncoding: The
BoolEncoding
to use..numeric
by default. - dataEncoding: The
DataEncoding
to use..base64
by default. - dateEncoding: The
DateEncoding
to use..deferredToDate
by default. - keyEncoding: The
KeyEncoding
to use..useDefaultKeys
by default. - spaceEncoding: The
SpaceEncoding
to use..percentEscaped
by default. - allowedCharacters: The
CharacterSet
of allowed (non-escaped) characters..afURLQueryAllowed
by default.
Whether or not to sort the encoded key value pairs.
let alphabetizeKeyValuePairs: Bool
The ArrayEncoding
to use.
let arrayEncoding: ArrayEncoding
The BoolEncoding
to use.
let boolEncoding: BoolEncoding
THe DataEncoding
to use.
let dataEncoding: DataEncoding
The DateEncoding
to use.
let dateEncoding: DateEncoding
The KeyEncoding
to use.
let keyEncoding: KeyEncoding
The SpaceEncoding
to use.
let spaceEncoding: SpaceEncoding
The CharacterSet
of allowed (non-escaped) characters.
var allowedCharacters: CharacterSet
Encodes the value
as a URL form encoded String
.
public func encode(_ value: Encodable) throws -> String
- value: The
Encodable
value.`
An Error
or EncodingError
instance if encoding fails.
The encoded String
.
Encodes the value as Data
. This is performed by first creating an encoded String
and then returning the
.utf8
data.
public func encode(_ value: Encodable) throws -> Data
- value: The
Encodable
value.
An Error
or EncodingError
instance if encoding fails.
The encoded Data
.
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