Skip to content

Instantly share code, notes, and snippets.

@nolanw
nolanw / URLRequest+FormURLEncoded.swift
Last active May 11, 2023 20:38
Swift x-www-form-urlencoded
// Public domain - https://gist.github.com/nolanw/14b277903a2ba446f75202a6bfd55977
import Foundation
extension URLRequest {
/**
Configures the URL request for `application/x-www-form-urlencoded` data. The request's `httpBody` is set, and values are set for HTTP header fields `Content-Type` and `Content-Length`.
- Parameter queryItems: The (name, value) pairs to encode and set as the request's body.