Gemini/GeminiProtocol/GeminiRequest.swift

32 lines
550 B
Swift

//
// GeminiRequest.swift
// Gemini
//
// Created by Shadowfacts on 7/12/20.
//
import Foundation
struct GeminiRequest {
let url: URL
init(url: URL) throws {
if url.absoluteString.count > 1024 {
throw Error.urlTooLong
}
self.url = url
}
var data: Data {
var data = url.absoluteString.data(using: .utf8)!
data.append(contentsOf: [13, 10]) // <CR><LF>
return data
}
}
extension GeminiRequest {
enum Error: Swift.Error {
case urlTooLong
}
}