HttpData

public enum HttpData

The HttpData enum is an empty enumeration that is merely used to put different implementations of HttpBody into a common scope. Out of the box, Squid provides HttpData.Empty, HttpData.Json and HttpData.Image which all implement the HttpBody protocol.

  • The empty HTTP body is used as default for all requests and sets no HTTP body at all.

    See more

    Declaration

    Swift

    public struct Empty : HttpBody, Hashable
  • The image HTTP body can be used to attach an image to a request. Currently, only PNG and JPEG images are supported. When adding the image’s data to the body of the request, this body also sets the “Content-Type” header to the appropriate MIME type as well as the “Content-Length” header to the size of the image in bytes.

    See more

    Declaration

    Swift

    public struct Image : HttpBody, Hashable
  • The JSON HTTP body is presumably the most commonly used non-empty body for HTTP requests. It encodes an encodable type as JSON and sets the body of an HTTP request as well as the “Content-Type” header to “application/json”.

    See more

    Declaration

    Swift

    public struct Json<T> : HttpBody where T : Encodable
    extension HttpData.Json: Equatable where T: Equatable
    extension HttpData.Json: Hashable where T: Hashable