Skip to content
Permalink
Browse files

Initial commit

  • Loading branch information
YOCKOW committed Oct 1, 2017
0 parents commit 3108a3dd5a38b1ac7b7b11ef5f436b3656b0039c
@@ -0,0 +1,7 @@
.DS_Store
/.build
/Packages
/*.xcodeproj

/SwiftKeywords.yml

@@ -0,0 +1,31 @@
matrix:
include:
- os: linux
dist: trusty
sudo: required
language: ruby
before_install:
- export SYM_INSTALL_URL="https://gist.githubusercontent.com/YOCKOW/52756b7061c4e92ca960cf2ff9506560/raw/847fc88e5db0c488b610e2f7bc5f0e06c0b74892/symbolic-install"
- export CLANG_ARCHIVE_URL="http://releases.llvm.org/5.0.0/clang+llvm-5.0.0-linux-x86_64-ubuntu14.04.tar.xz"
- export SWIFT_ARCHIVE_URL="https://swift.org/builds/swift-4.0-release/ubuntu1404/swift-4.0-RELEASE/swift-4.0-RELEASE-ubuntu14.04.tar.gz"
- curl ${CLANG_ARCHIVE_URL} -o ../clang.tar.xz
- curl ${SWIFT_ARCHIVE_URL} -o ../swift.tar.gz
- mkdir ../clang
- mkdir ../swift
- tar xJf ../clang.tar.xz -C ../clang --strip-components 1
- tar xzf ../swift.tar.gz -C ../swift --strip-components 2
- curl ${SYM_INSTALL_URL} -o ../symbolic-install
- chmod a+x ../symbolic-install
- sudo ../symbolic-install ../clang > /dev/null
- sudo ../symbolic-install ../swift > /dev/null
- sudo ldconfig
- os: osx
osx_image: xcode9
sudo: required
language: objective-c

script:
- swift build
- swift test
- swift build --configuration release

@@ -0,0 +1,18 @@
The MIT License (MIT)
Copyright (c) 2017 YOCKOW

Permission is hereby granted, free of charge, to any person obtaining a copy of this software
and associated documentation files (the "Software"), to deal in the Software without restriction,
including without limitation the rights to use, copy, modify, merge, publish, distribute,
sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial
portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES
OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

@@ -0,0 +1,24 @@
// swift-tools-version:4.0
// The swift-tools-version declares the minimum version of Swift required to build this package.
import PackageDescription

let package = Package(
name:"CGIResponder",
products:[
// Products define the executables and libraries produced by a package, and make them visible to other packages.
.library(name:"SwiftCGIResponder", type:.dynamic, targets:["CGIResponder"]),
],
dependencies:[
// Dependencies declare other packages that this package depends on.
// .package(url: /* package url */, from: "1.0.0"),
],
targets:[
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
// Targets can depend on other targets in this package, and on products in packages which this package depends on.
.target(name:"CGIResponder", dependencies:[]),
.testTarget(name:"CGIResponderTests", dependencies:["CGIResponder"]),
],
swiftLanguageVersions:[4]
)

@@ -0,0 +1,18 @@
# What is `SwiftCGIResponder`?
`SwiftCGIResponder` will provide miscellaneous functions you may use when you write CGI programs in Swift.
It's an experimental library under development, and useless so far. (I rebuild the library from scratch, once I had created.)

# Requirements
* Swift >= 4.0 + CoreFoundation + Foundation
* macOS >= 10.12 or Linux
* HTTP server software (e.g. Apache or similar software)

# Usage
Yet Unpublished

# How to install
Yet Unpublished

# License
MIT License.
See "LICENSE.txt" for more information.
@@ -0,0 +1,20 @@
/***************************************************************************************************
CGIResponder.swift
© 2017 YOCKOW.
Licensed under MIT License.
See "LICENSE.txt" for more information.
**************************************************************************************************/

/**
# CGIResponder
The principal structure that can respond to the client.
*/
public struct CGIResponder {
public var status: HTTPStatusCode

public init(status: HTTPStatusCode = .ok) {
self.status = status
}
}
@@ -0,0 +1,133 @@
/***************************************************************************************************
HTTPStatusCode.swift
This file was created automatically
from https://www.iana.org/assignments/http-status-codes/http-status-codes-1.csv
at 2017-10-01T18:21:51+09:00
**************************************************************************************************/

public enum HTTPStatusCode: UInt16 {
case `continue` = 100
case switchingProtocols = 101
case processing = 102
case ok = 200
case created = 201
case accepted = 202
case nonAuthoritativeInformation = 203
case noContent = 204
case resetContent = 205
case partialContent = 206
case multiStatus = 207
case alreadyReported = 208
case imUsed = 226
case multipleChoices = 300
case movedPermanently = 301
case found = 302
case seeOther = 303
case notModified = 304
case useProxy = 305
case temporaryRedirect = 307
case permanentRedirect = 308
case badRequest = 400
case unauthorized = 401
case paymentRequired = 402
case forbidden = 403
case notFound = 404
case methodNotAllowed = 405
case notAcceptable = 406
case proxyAuthenticationRequired = 407
case requestTimeout = 408
case conflict = 409
case gone = 410
case lengthRequired = 411
case preconditionFailed = 412
case payloadTooLarge = 413
case uriTooLong = 414
case unsupportedMediaType = 415
case rangeNotSatisfiable = 416
case expectationFailed = 417
case misdirectedRequest = 421
case unprocessableEntity = 422
case locked = 423
case failedDependency = 424
case upgradeRequired = 426
case preconditionRequired = 428
case tooManyRequests = 429
case requestHeaderFieldsTooLarge = 431
case unavailableForLegalReasons = 451
case internalServerError = 500
case notImplemented = 501
case badGateway = 502
case serviceUnavailable = 503
case gatewayTimeout = 504
case httpVersionNotSupported = 505
case variantAlsoNegotiates = 506
case insufficientStorage = 507
case loopDetected = 508
case notExtended = 510
case networkAuthenticationRequired = 511
}
extension HTTPStatusCode{
public var reasonPhrase: String {
switch self {
case .continue: return "Continue" // 100
case .switchingProtocols: return "Switching Protocols" // 101
case .processing: return "Processing" // 102
case .ok: return "OK" // 200
case .created: return "Created" // 201
case .accepted: return "Accepted" // 202
case .nonAuthoritativeInformation: return "Non-Authoritative Information" // 203
case .noContent: return "No Content" // 204
case .resetContent: return "Reset Content" // 205
case .partialContent: return "Partial Content" // 206
case .multiStatus: return "Multi-Status" // 207
case .alreadyReported: return "Already Reported" // 208
case .imUsed: return "IM Used" // 226
case .multipleChoices: return "Multiple Choices" // 300
case .movedPermanently: return "Moved Permanently" // 301
case .found: return "Found" // 302
case .seeOther: return "See Other" // 303
case .notModified: return "Not Modified" // 304
case .useProxy: return "Use Proxy" // 305
case .temporaryRedirect: return "Temporary Redirect" // 307
case .permanentRedirect: return "Permanent Redirect" // 308
case .badRequest: return "Bad Request" // 400
case .unauthorized: return "Unauthorized" // 401
case .paymentRequired: return "Payment Required" // 402
case .forbidden: return "Forbidden" // 403
case .notFound: return "Not Found" // 404
case .methodNotAllowed: return "Method Not Allowed" // 405
case .notAcceptable: return "Not Acceptable" // 406
case .proxyAuthenticationRequired: return "Proxy Authentication Required" // 407
case .requestTimeout: return "Request Timeout" // 408
case .conflict: return "Conflict" // 409
case .gone: return "Gone" // 410
case .lengthRequired: return "Length Required" // 411
case .preconditionFailed: return "Precondition Failed" // 412
case .payloadTooLarge: return "Payload Too Large" // 413
case .uriTooLong: return "URI Too Long" // 414
case .unsupportedMediaType: return "Unsupported Media Type" // 415
case .rangeNotSatisfiable: return "Range Not Satisfiable" // 416
case .expectationFailed: return "Expectation Failed" // 417
case .misdirectedRequest: return "Misdirected Request" // 421
case .unprocessableEntity: return "Unprocessable Entity" // 422
case .locked: return "Locked" // 423
case .failedDependency: return "Failed Dependency" // 424
case .upgradeRequired: return "Upgrade Required" // 426
case .preconditionRequired: return "Precondition Required" // 428
case .tooManyRequests: return "Too Many Requests" // 429
case .requestHeaderFieldsTooLarge: return "Request Header Fields Too Large" // 431
case .unavailableForLegalReasons: return "Unavailable For Legal Reasons" // 451
case .internalServerError: return "Internal Server Error" // 500
case .notImplemented: return "Not Implemented" // 501
case .badGateway: return "Bad Gateway" // 502
case .serviceUnavailable: return "Service Unavailable" // 503
case .gatewayTimeout: return "Gateway Timeout" // 504
case .httpVersionNotSupported: return "HTTP Version Not Supported" // 505
case .variantAlsoNegotiates: return "Variant Also Negotiates" // 506
case .insufficientStorage: return "Insufficient Storage" // 507
case .loopDetected: return "Loop Detected" // 508
case .notExtended: return "Not Extended" // 510
case .networkAuthenticationRequired: return "Network Authentication Required" // 511
}
}
}
@@ -0,0 +1,12 @@
import XCTest
@testable import CGIResponder

class CGIResponderTests: XCTestCase {
func testResponse() {
XCTAssertEqual("", "")
}

static var allTests: [(String, (CGIResponderTests) -> () -> Void)] = [
("testResponse", testResponse),
]
}
@@ -0,0 +1,6 @@
import XCTest
@testable import CGIResponderTests

XCTMain([
testCase(CGIResponderTests.allTests),
])

0 comments on commit 3108a3d

Please sign in to comment.
You can’t perform that action at this time.