Repository: vapor/vapor
File: Sources/Vapor/Client/ClientRequest.swift (Swift)

Code before:
import NIOCore
import NIOHTTP1
import Foundation

public struct ClientRequest {
    public var method: HTTPMethod
    public var url: URI
    public var headers: HTTPHeaders
    public var body: ByteBuffer?
    public var timeout: TimeAmount?
    private let byteBufferAllocator: ByteBufferAllocator

    public init(
        method: HTTPMethod = .GET,
        url: URI = "/",
        headers: HTTPHeaders = [:],
        body: ByteBuffer? = nil,
        timeout: TimeAmount? = nil,
        byteBufferAllocator: ByteBufferAllocator = ByteBufferAllocator()
    ) {
        self.method = method
        self.url = url
        self.headers = headers
        self.body = body
        self.timeout = timeout
        self.byteBufferAllocator = byteBufferAllocator
    }
}

extension ClientRequest {
    private struct _URLQueryContainer: URLQueryContainer {
        var url: URI

        func decode<D>(_ decodable: D.Type, using decoder: URLQueryDecoder) throws -> D
            where D: Decodable
        {
            return try decoder.decode(D.self, from: self.url)
        }

        mutating func encode<E>(_ encodable: E, using encoder: URLQueryEncoder) throws
            where E: Encodable
        {
            try encoder.encode(encodable, to: &self.url)
        }
    }

Review comment (suggestion):
For 100% pedantic source compatibility, this should be written this way:
```suggestion
    public init(
        method: HTTPMethod = .GET,
        url: URI = "/",
        headers: HTTPHeaders = [:],
        body: ByteBuffer? = nil,
        byteBufferAllocator: ByteBufferAllocator = ByteBufferAllocator()
    ) {
        self.init(
            method: method,
            url: url,
            headers: headers,
            timeout: nil,
            body: body,
            byteBufferAllocator: byteBufferAllocator
        )
    }
    
    public init(
        method: HTTPMethod = .GET,
        url: URI = "/",
        headers: HTTPHeaders = [:],
        body: ByteBuffer? = nil,
        timeout: TimeAmount?,
        byteBufferAllocator: ByteBufferAllocator = ByteBufferAllocator()
    ) {
```

Code after:
import NIOCore
import NIOHTTP1
import Foundation

public struct ClientRequest {
    public var method: HTTPMethod
    public var url: URI
    public var headers: HTTPHeaders
    public var body: ByteBuffer?
    public var timeout: TimeAmount?
    private let byteBufferAllocator: ByteBufferAllocator

    public init(
        method: HTTPMethod = .GET,
        url: URI = "/",
        headers: HTTPHeaders = [:],
        body: ByteBuffer? = nil,
        timeout: TimeAmount?,
        byteBufferAllocator: ByteBufferAllocator = ByteBufferAllocator()
    ) {
        self.method = method
        self.url = url
        self.headers = headers
        self.body = body
        self.timeout = timeout
        self.byteBufferAllocator = byteBufferAllocator
    }

    public init(
        method: HTTPMethod = .GET,
        url: URI = "/",
        headers: HTTPHeaders = [:],
        body: ByteBuffer? = nil,
        byteBufferAllocator: ByteBufferAllocator = ByteBufferAllocator()
    ) {
        self.init(method: method,
                  url: url,
                  headers: headers,
                  body: body,
                  timeout: nil,
                  byteBufferAllocator: byteBufferAllocator)
    }
}

extension ClientRequest {