From 3edcb3fb1565058752b38cbd64439e976e924b60 Mon Sep 17 00:00:00 2001 From: mtgto Date: Mon, 9 Nov 2020 00:39:42 +0900 Subject: [PATCH 01/28] Fix misspell serialise --- XCode/Sources/HttpResponse.swift | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/XCode/Sources/HttpResponse.swift b/XCode/Sources/HttpResponse.swift index 362db8be..dfc16e06 100644 --- a/XCode/Sources/HttpResponse.swift +++ b/XCode/Sources/HttpResponse.swift @@ -51,8 +51,8 @@ public enum HttpResponseBody { try $0.write(data) }) case .htmlBody(let body): - let serialised = "\(body)" - let data = [UInt8](serialised.utf8) + let serialized = "\(body)" + let data = [UInt8](serialized.utf8) return (data.count, { try $0.write(data) }) @@ -61,14 +61,14 @@ public enum HttpResponseBody { try $0.write(data) }) case .custom(let object, let closure): - let serialised = try closure(object) - let data = [UInt8](serialised.utf8) + let serialized = try closure(object) + let data = [UInt8](serialized.utf8) return (data.count, { try $0.write(data) }) } } catch { - let data = [UInt8]("Serialisation error: \(error)".utf8) + let data = [UInt8]("Serialization error: \(error)".utf8) return (data.count, { try $0.write(data) }) From 31346bed682a31477b11fbcfb017f94e93ea1365 Mon Sep 17 00:00:00 2001 From: mtgto Date: Mon, 9 Nov 2020 00:40:52 +0900 Subject: [PATCH 02/28] Add Content-Type to HttpBody and Text HttpResponse --- XCode/Sources/HttpResponse.swift | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/XCode/Sources/HttpResponse.swift b/XCode/Sources/HttpResponse.swift index 362db8be..582f17c0 100644 --- a/XCode/Sources/HttpResponse.swift +++ b/XCode/Sources/HttpResponse.swift @@ -136,7 +136,8 @@ public enum HttpResponse { case .ok(let body): switch body { case .json: headers["Content-Type"] = "application/json" - case .html: headers["Content-Type"] = "text/html" + case .html, .htmlBody: headers["Content-Type"] = "text/html" + case .text: headers["Content-Type"] = "text/plain" case .data(_, let contentType): headers["Content-Type"] = contentType default:break } From 4c4643eb298d17a3b52af040213f715fcb34eac6 Mon Sep 17 00:00:00 2001 From: mtgto Date: Fri, 13 Nov 2020 22:26:38 +0900 Subject: [PATCH 03/28] Update the CHANGELOG --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index cd59d0a7..8c786370 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,10 @@ All notable changes to this project will be documented in this file. Changes not # [Unreleased] +## Fixed + +- Fix misspell `serialise`. ([#473](https://github.com/httpswift/swifter/pull/473)) by [@mtgto](https://github.com/mtgto) + # [1.5.0] ## Added From bbcefb856df45c0fbe21f48c026bf3543a3db86f Mon Sep 17 00:00:00 2001 From: mtgto Date: Fri, 13 Nov 2020 22:29:21 +0900 Subject: [PATCH 04/28] Update the CHANGELOG --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index cd59d0a7..77d8bb57 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,10 @@ All notable changes to this project will be documented in this file. Changes not # [Unreleased] +## Added + +- Set `Content-Type` to HttpBody and Text HttpResponse. ([#474](https://github.com/httpswift/swifter/pull/474)) by [@mtgto](https://github.com/mtgto) + # [1.5.0] ## Added From ee567a23def968c9bf52b8317df4614226d942a4 Mon Sep 17 00:00:00 2001 From: Michael Enger Date: Thu, 11 Feb 2021 22:45:19 +0100 Subject: [PATCH 05/28] Added support for using ** as a catch-all at the end of a route --- XCode/Sources/HttpRouter.swift | 6 ++++++ XCode/Tests/SwifterTestsHttpRouter.swift | 12 ++++++++++++ 2 files changed, 18 insertions(+) diff --git a/XCode/Sources/HttpRouter.swift b/XCode/Sources/HttpRouter.swift index 3dac20fd..1429627e 100644 --- a/XCode/Sources/HttpRouter.swift +++ b/XCode/Sources/HttpRouter.swift @@ -151,6 +151,12 @@ open class HttpRouter { } if let startStarNode = node.nodes["**"] { + if startStarNode.isEndOfRoute { + // ** at the end of a route works as a catch-all + matchedNodes.append(startStarNode) + return + } + let startStarNodeKeys = startStarNode.nodes.keys currentIndex += 1 while currentIndex < count, let pathToken = pattern[currentIndex].removingPercentEncoding { diff --git a/XCode/Tests/SwifterTestsHttpRouter.swift b/XCode/Tests/SwifterTestsHttpRouter.swift index bf26ea28..c4b06df5 100644 --- a/XCode/Tests/SwifterTestsHttpRouter.swift +++ b/XCode/Tests/SwifterTestsHttpRouter.swift @@ -85,6 +85,18 @@ class SwifterTestsHttpRouter: XCTestCase { XCTAssertNil(router.route(nil, path: "/a/e/f/g")) } + func testHttpRouterMultiplePathSegmentWildcardTail() { + + router.register(nil, path: "/a/b/**", handler: { _ in + return .ok(.htmlBody("OK")) + }) + + XCTAssertNil(router.route(nil, path: "/")) + XCTAssertNil(router.route(nil, path: "/a")) + XCTAssertNotNil(router.route(nil, path: "/a/b/c/d/e/f/g")) + XCTAssertNil(router.route(nil, path: "/a/e/f/g")) + } + func testHttpRouterEmptyTail() { router.register(nil, path: "/a/b/", handler: { _ in From 6e1ca6ad08472dd054e2c33e22b5ac36284b953d Mon Sep 17 00:00:00 2001 From: Michael Enger Date: Thu, 11 Feb 2021 22:59:27 +0100 Subject: [PATCH 06/28] Update changelog --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index cd59d0a7..a1686459 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,9 @@ All notable changes to this project will be documented in this file. Changes not # [Unreleased] +## Added +- Add support for using `**` as a catch-all at the end of a route. ([#479](https://github.com/httpswift/swifter/pull/479)) by [@michaelenger](https://github.com/michaelenger) + # [1.5.0] ## Added From 0187b7984501c85b73ec71f5985b08c2bd13ca4e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 29 Mar 2021 22:36:44 +0000 Subject: [PATCH 07/28] Bump kramdown from 2.3.0 to 2.3.1 Bumps [kramdown](https://github.com/gettalong/kramdown) from 2.3.0 to 2.3.1. - [Release notes](https://github.com/gettalong/kramdown/releases) - [Changelog](https://github.com/gettalong/kramdown/blob/master/doc/news.page) - [Commits](https://github.com/gettalong/kramdown/commits) Signed-off-by: dependabot[bot] --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index edf8c516..79e391f7 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -34,7 +34,7 @@ GEM faraday (>= 0.8) git (1.7.0) rchardet (~> 1.8) - kramdown (2.3.0) + kramdown (2.3.1) rexml kramdown-parser-gfm (1.1.0) kramdown (~> 2.0) From 1f7f6bef3a08156aafe0c46efd1fe6dde05b827e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 30 Apr 2021 20:54:13 +0000 Subject: [PATCH 08/28] Bump rexml from 3.2.4 to 3.2.5 Bumps [rexml](https://github.com/ruby/rexml) from 3.2.4 to 3.2.5. - [Release notes](https://github.com/ruby/rexml/releases) - [Changelog](https://github.com/ruby/rexml/blob/master/NEWS.md) - [Commits](https://github.com/ruby/rexml/compare/v3.2.4...v3.2.5) Signed-off-by: dependabot[bot] --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index edf8c516..1d6f6738 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -48,7 +48,7 @@ GEM public_suffix (4.0.6) rake (13.0.1) rchardet (1.8.0) - rexml (3.2.4) + rexml (3.2.5) sawyer (0.8.2) addressable (>= 2.3.5) faraday (> 0.8, < 2.0) From e1e4f127802ea97ecbf416db43125ce3ac527f72 Mon Sep 17 00:00:00 2001 From: Victor Sigler Date: Fri, 7 May 2021 15:09:38 -0400 Subject: [PATCH 09/28] Rename the XCode folder to Xcode --- .github/workflows/macos-tests.yml | 8 ++++---- .gitignore | 2 +- .swiftlint.yml | 2 +- Dangerfile | 6 +++--- Package.swift | 4 ++-- README.md | 2 +- Swifter.podspec | 2 +- 7 files changed, 13 insertions(+), 13 deletions(-) diff --git a/.github/workflows/macos-tests.yml b/.github/workflows/macos-tests.yml index 4daba501..9989f63f 100644 --- a/.github/workflows/macos-tests.yml +++ b/.github/workflows/macos-tests.yml @@ -21,19 +21,19 @@ jobs: mkdir -p tmp/test-results/ - name: Run Unit Test - macOS run: | - cd XCode + cd Xcode set -o pipefail && xcodebuild test -scheme SwifterMac -sdk macosx -destination "arch=x86_64" | xcpretty -c -r html --output $TEST_REPORTS/macOS.html - name: Run Unit Test - iOS run: | - cd XCode + cd Xcode set -o pipefail && xcodebuild test -scheme SwifteriOS -sdk iphonesimulator -destination "name=iPhone 8" | xcpretty -c -r html --output $TEST_REPORTS/iOS.html - name: Run Unit Test - tvOS run: | - cd XCode + cd Xcode set -o pipefail && xcodebuild test -scheme SwiftertvOS -sdk appletvsimulator -destination "name=Apple TV 4K (at 1080p)" | xcpretty -c -r html --output $TEST_REPORTS/tvOS.html - name: Run Unit Test - Swift Package Manager run: | - cd XCode + cd Xcode swift build && swift test - name: Archive Test results uses: actions/upload-artifact@v1 diff --git a/.gitignore b/.gitignore index 239c7866..98201867 100644 --- a/.gitignore +++ b/.gitignore @@ -27,4 +27,4 @@ DerivedData .build/ Packages/ -/XCode/.DS_Store +/Xcode/.DS_Store diff --git a/.swiftlint.yml b/.swiftlint.yml index b66fc6ce..c90ba6f9 100644 --- a/.swiftlint.yml +++ b/.swiftlint.yml @@ -16,6 +16,6 @@ disabled_rules: excluded: # paths to ignore during linting. Takes precedence over `included`. - LinuxMain.swift - - XCode/Tests/XCTestManifests.swift + - Xcode/Tests/XCTestManifests.swift - Tests/XCTestManifests.swift - Package.swift diff --git a/Dangerfile b/Dangerfile index b75f2e29..e5d373de 100644 --- a/Dangerfile +++ b/Dangerfile @@ -26,10 +26,10 @@ swiftlint.config_file = '.swiftlint.yml' swiftlint.lint_files # Warn when new tests are added but the XCTestManifests wasn't updated to run on Linux -tests_added_or_modified = !git.modified_files.grep(/XCode\/Tests/).empty? || !git.added_files.grep(/XCode\/Tests/).empty? -xc_manifest_updated = !git.modified_files.grep(/XCode\/Tests\/XCTestManifests.swift/).empty? +tests_added_or_modified = !git.modified_files.grep(/Xcode\/Tests/).empty? || !git.added_files.grep(/Xcode\/Tests/).empty? +xc_manifest_updated = !git.modified_files.grep(/Xcode\/Tests\/XCTestManifests.swift/).empty? if tests_added_or_modified && !xc_manifest_updated - warn("It seems like you've added new tests to the library. If that's the case, please update the [XCTestManifests.swift](https://github.com/httpswift/swifter/blob/stable/XCode/Tests/XCTestManifests.swift) file running in your terminal the command `swift test --generate-linuxmain`.") + warn("It seems like you've added new tests to the library. If that's the case, please update the [XCTestManifests.swift](https://github.com/httpswift/swifter/blob/stable/Xcode/Tests/XCTestManifests.swift) file running in your terminal the command `swift test --generate-linuxmain`.") # This is a temporary warning to remove the entry for the failed test until we solve the issue in Linux warn("If you ran the command `swift test --generate-linuxmain` in your terminal, please remove the line `testCase(IOSafetyTests.__allTests__IOSafetyTests),` from `public func __allTests() -> [XCTestCaseEntry]` in the bottom of the file. For more reference see [#366](https://github.com/httpswift/swifter/issues/366).") diff --git a/Package.swift b/Package.swift index cfa4c833..b8b72e32 100644 --- a/Package.swift +++ b/Package.swift @@ -16,7 +16,7 @@ let package = Package( .target( name: "Swifter", dependencies: [], - path: "XCode/Sources" + path: "Xcode/Sources" ), .target( @@ -31,7 +31,7 @@ let package = Package( dependencies: [ "Swifter" ], - path: "XCode/Tests" + path: "Xcode/Tests" ) ] ) \ No newline at end of file diff --git a/README.md b/README.md index 75461d25..c9aa41ac 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ Tiny http server engine written in [Swift](https://developer.apple.com/swift/) programming language. ### Branches -`* stable` - lands on CocoaPods and others. Supports the latest non-beta XCode and SPM. Stable. +`* stable` - lands on CocoaPods and others. Supports the latest non-beta Xcode and SPM. Stable. `* master` - stable branch plus experimental web-framework layer. diff --git a/Swifter.podspec b/Swifter.podspec index e876335c..79766903 100644 --- a/Swifter.podspec +++ b/Swifter.podspec @@ -10,7 +10,7 @@ Pod::Spec.new do |s| s.osx.deployment_target = "10.10" s.tvos.deployment_target = "9.0" s.source = { :git => "https://github.com/httpswift/swifter.git", :tag => "1.5.0" } - s.source_files = 'XCode/Sources/*.{swift}' + s.source_files = 'Xcode/Sources/*.{swift}' s.swift_version = '4.2' end \ No newline at end of file From e03a9c7d7aba2fb12e7bca0146e85c2c4881bbad Mon Sep 17 00:00:00 2001 From: Victor Sigler Date: Fri, 7 May 2021 15:26:36 -0400 Subject: [PATCH 10/28] Update the Danger job and the Ruby dependencies --- .github/workflows/danger.yml | 35 ++++++++++++++--------------------- Gemfile.lock | 24 ++++++++++++++++-------- 2 files changed, 30 insertions(+), 29 deletions(-) diff --git a/.github/workflows/danger.yml b/.github/workflows/danger.yml index 560ebb10..a28ed1b1 100644 --- a/.github/workflows/danger.yml +++ b/.github/workflows/danger.yml @@ -1,32 +1,25 @@ name: Danger + on: pull_request: + types: [opened, synchronize, edited] branches: - - stable + - stable jobs: Danger: - runs-on: macos-latest + runs-on: ubuntu-18.04 steps: - - uses: actions/checkout@v2 - - name: Cache Bundle Dependencies - uses: actions/cache@v1 - with: - path: vendor/bundle - key: 1-gems-{{ checksum "Gemfile.lock" }} - restore-keys: 1-gems- - - name: Set Ruby Version - uses: actions/setup-ruby@v1 + - uses: actions/checkout@v1 + + - uses: ruby/setup-ruby@v1 with: - ruby-version: 2.6 - - name: Install Ruby Dependencies + ruby-version: 2.6 # Not needed with a .ruby-version file + bundler-cache: true # runs 'bundle install' and caches installed gems automatically + + - name: Danger run: | - bundle config path vendor/bundle - bundle check || bundle install - env: - BUNDLE_JOBS: 4 - BUNDLE_RETRY: 3 - - name: Running Danger - run: bundle exec danger + bundle exec danger --fail-on-errors=true + shell: bash env: - DANGER_GITHUB_API_TOKEN: ${{ secrets.DANGER_GITHUB_API_TOKEN }} + DANGER_GITHUB_API_TOKEN: ${{ secrets.BOT_ACCESS_TOKEN }} \ No newline at end of file diff --git a/Gemfile.lock b/Gemfile.lock index 31ae580c..056e8b4a 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -11,7 +11,7 @@ GEM colored2 (3.1.2) cork (0.3.0) colored2 (~> 3.1) - danger (8.0.5) + danger (8.2.3) claide (~> 1.0) claide-plugins (>= 0.9.2) colored2 (~> 3.1) @@ -23,16 +23,23 @@ GEM kramdown-parser-gfm (~> 1.0) no_proxy_fix octokit (~> 4.7) - terminal-table (~> 1) - danger-swiftlint (0.24.4) + terminal-table (>= 1, < 4) + danger-swiftlint (0.26.0) danger rake (> 10) thor (~> 0.19) - faraday (1.0.1) + faraday (1.4.1) + faraday-excon (~> 1.1) + faraday-net_http (~> 1.0) + faraday-net_http_persistent (~> 1.1) multipart-post (>= 1.2, < 3) + ruby2_keywords (>= 0.0.4) + faraday-excon (1.1.0) faraday-http-cache (2.2.0) faraday (>= 0.8) - git (1.7.0) + faraday-net_http (1.0.1) + faraday-net_http_persistent (1.1.0) + git (1.8.1) rchardet (~> 1.8) kramdown (2.3.1) rexml @@ -41,18 +48,19 @@ GEM multipart-post (2.1.1) nap (1.1.0) no_proxy_fix (0.1.2) - octokit (4.18.0) + octokit (4.21.0) faraday (>= 0.9) sawyer (~> 0.8.0, >= 0.5.3) open4 (1.3.4) public_suffix (4.0.6) - rake (13.0.1) + rake (13.0.3) rchardet (1.8.0) rexml (3.2.5) + ruby2_keywords (0.0.4) sawyer (0.8.2) addressable (>= 2.3.5) faraday (> 0.8, < 2.0) - terminal-table (1.8.0) + terminal-table (3.0.0) unicode-display_width (~> 1.1, >= 1.1.1) thor (0.20.3) unicode-display_width (1.7.0) From 577088a53c0c26b30c0d7fa019c4fd067eaa9077 Mon Sep 17 00:00:00 2001 From: Victor Sigler Date: Fri, 7 May 2021 15:32:09 -0400 Subject: [PATCH 11/28] Update the CHANGELOG --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8c786370..89d2f17d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,7 +20,8 @@ All notable changes to this project will be documented in this file. Changes not ## Fixed -- Fix misspell `serialise`. ([#473](https://github.com/httpswift/swifter/pull/473)) by [@mtgto](https://github.com/mtgto) +* Fix misspell `serialise`. ([#473](https://github.com/httpswift/swifter/pull/473)) by [@mtgto](https://github.com/mtgto) +* Fix an issue causing Danger was not working properly. ([#486](https://github.com/httpswift/swifter/pull/486)) by [@Vkt0r](https://github.com/Vkt0r) # [1.5.0] From 0d338b29ecc110a9dcd41b1856ff92487014e561 Mon Sep 17 00:00:00 2001 From: Victor Sigler Date: Fri, 7 May 2021 16:05:44 -0400 Subject: [PATCH 12/28] Update the Swiftlint rules --- XCode/LinuxMain.swift | 1 - XCode/Tests/SwifterTestsHttpParser.swift | 2 +- XCode/Tests/SwifterTestsWebSocketSession.swift | 2 +- 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/XCode/LinuxMain.swift b/XCode/LinuxMain.swift index 42b4a191..581f29f5 100644 --- a/XCode/LinuxMain.swift +++ b/XCode/LinuxMain.swift @@ -1,5 +1,4 @@ import XCTest - import SwifterTests var tests = [XCTestCaseEntry]() diff --git a/XCode/Tests/SwifterTestsHttpParser.swift b/XCode/Tests/SwifterTestsHttpParser.swift index 0630adbb..b28c2190 100644 --- a/XCode/Tests/SwifterTestsHttpParser.swift +++ b/XCode/Tests/SwifterTestsHttpParser.swift @@ -50,7 +50,7 @@ class SwifterTestsHttpParser: XCTestCase { } } - // swiftlint:disable function_body_length + // swiftlint:disable function_body_length cyclomatic_complexity func testParser() { let parser = HttpParser() diff --git a/XCode/Tests/SwifterTestsWebSocketSession.swift b/XCode/Tests/SwifterTestsWebSocketSession.swift index 97a02988..85056464 100644 --- a/XCode/Tests/SwifterTestsWebSocketSession.swift +++ b/XCode/Tests/SwifterTestsWebSocketSession.swift @@ -29,7 +29,7 @@ class SwifterTestsWebSocketSession: XCTestCase { } } - // swiftlint:disable function_body_length + // swiftlint:disable function_body_length cyclomatic_complexity func testParser() { do { From 140389655781e5943ff341106616d0afbbb5773a Mon Sep 17 00:00:00 2001 From: Victor Sigler Date: Fri, 7 May 2021 16:15:42 -0400 Subject: [PATCH 13/28] Rename in Git the XCode folder to Xcode --- {XCode => Xcode}/LinuxMain.swift | 0 {XCode => Xcode}/Resources/logo.png | Bin {XCode => Xcode}/Sources/DemoServer.swift | 0 {XCode => Xcode}/Sources/Errno.swift | 0 {XCode => Xcode}/Sources/Files.swift | 0 {XCode => Xcode}/Sources/HttpParser.swift | 0 {XCode => Xcode}/Sources/HttpRequest.swift | 0 {XCode => Xcode}/Sources/HttpResponse.swift | 0 {XCode => Xcode}/Sources/HttpRouter.swift | 0 {XCode => Xcode}/Sources/HttpServer.swift | 0 {XCode => Xcode}/Sources/HttpServerIO.swift | 0 {XCode => Xcode}/Sources/MimeTypes.swift | 0 {XCode => Xcode}/Sources/Process.swift | 0 {XCode => Xcode}/Sources/Scopes.swift | 0 {XCode => Xcode}/Sources/Socket+File.swift | 0 {XCode => Xcode}/Sources/Socket+Server.swift | 0 {XCode => Xcode}/Sources/Socket.swift | 0 {XCode => Xcode}/Sources/String+BASE64.swift | 0 {XCode => Xcode}/Sources/String+File.swift | 0 {XCode => Xcode}/Sources/String+Misc.swift | 0 {XCode => Xcode}/Sources/String+SHA1.swift | 0 {XCode => Xcode}/Sources/WebSockets.swift | 0 {XCode => Xcode}/Swifter.xcodeproj/project.pbxproj | 0 .../project.xcworkspace/contents.xcworkspacedata | 0 .../xcshareddata/IDEWorkspaceChecks.plist | 0 .../xcshareddata/xcschemes/SwifterMac.xcscheme | 0 .../xcschemes/SwifterSampleOSX.xcscheme | 0 .../xcshareddata/xcschemes/SwifteriOS.xcscheme | 0 .../xcshareddata/xcschemes/SwifteriOSTests.xcscheme | 0 .../xcschemes/SwiftermacOSTests.xcscheme | 0 .../xcshareddata/xcschemes/SwiftertvOS.xcscheme | 0 .../xcschemes/SwiftertvOSTests.xcscheme | 0 {XCode => Xcode}/SwifterMac/Info.plist | 0 {XCode => Xcode}/SwifterMac/SwifterMac.h | 0 {XCode => Xcode}/SwifterSampleOSX/main.swift | 0 {XCode => Xcode}/SwifterSampleiOS/AppDelegate.swift | 0 .../SwifterSampleiOS/Base.lproj/Main.storyboard | 0 .../AppIcon.appiconset/Contents.json | 0 .../LaunchImage.launchimage/Contents.json | 0 {XCode => Xcode}/SwifterSampleiOS/Info.plist | 0 .../SwifterSampleiOS/Launch Screen.storyboard | 0 .../SwifterSampleiOS/ViewController.swift | 0 {XCode => Xcode}/SwifteriOS/Info.plist | 0 {XCode => Xcode}/SwifteriOS/SwifteriOS.h | 0 {XCode => Xcode}/SwifteriOSTests/Info.plist | 0 {XCode => Xcode}/SwiftermacOSTests/Info.plist | 0 {XCode => Xcode}/SwiftertvOS/Info.plist | 0 {XCode => Xcode}/SwiftertvOS/SwiftertvOS.h | 0 {XCode => Xcode}/SwiftertvOSTests/Info.plist | 0 {XCode => Xcode}/Tests/IOSafetyTests.swift | 0 {XCode => Xcode}/Tests/MimeTypesTests.swift | 0 {XCode => Xcode}/Tests/PingServer.swift | 0 {XCode => Xcode}/Tests/ServerThreadingTests.swift | 0 {XCode => Xcode}/Tests/SwifterTestsHttpParser.swift | 0 .../Tests/SwifterTestsHttpResponseBody.swift | 0 {XCode => Xcode}/Tests/SwifterTestsHttpRouter.swift | 0 .../Tests/SwifterTestsStringExtensions.swift | 0 .../Tests/SwifterTestsWebSocketSession.swift | 0 {XCode => Xcode}/Tests/XCTestManifests.swift | 0 59 files changed, 0 insertions(+), 0 deletions(-) rename {XCode => Xcode}/LinuxMain.swift (100%) rename {XCode => Xcode}/Resources/logo.png (100%) rename {XCode => Xcode}/Sources/DemoServer.swift (100%) rename {XCode => Xcode}/Sources/Errno.swift (100%) rename {XCode => Xcode}/Sources/Files.swift (100%) rename {XCode => Xcode}/Sources/HttpParser.swift (100%) rename {XCode => Xcode}/Sources/HttpRequest.swift (100%) rename {XCode => Xcode}/Sources/HttpResponse.swift (100%) rename {XCode => Xcode}/Sources/HttpRouter.swift (100%) rename {XCode => Xcode}/Sources/HttpServer.swift (100%) rename {XCode => Xcode}/Sources/HttpServerIO.swift (100%) rename {XCode => Xcode}/Sources/MimeTypes.swift (100%) rename {XCode => Xcode}/Sources/Process.swift (100%) rename {XCode => Xcode}/Sources/Scopes.swift (100%) rename {XCode => Xcode}/Sources/Socket+File.swift (100%) rename {XCode => Xcode}/Sources/Socket+Server.swift (100%) rename {XCode => Xcode}/Sources/Socket.swift (100%) rename {XCode => Xcode}/Sources/String+BASE64.swift (100%) rename {XCode => Xcode}/Sources/String+File.swift (100%) rename {XCode => Xcode}/Sources/String+Misc.swift (100%) rename {XCode => Xcode}/Sources/String+SHA1.swift (100%) rename {XCode => Xcode}/Sources/WebSockets.swift (100%) rename {XCode => Xcode}/Swifter.xcodeproj/project.pbxproj (100%) rename {XCode => Xcode}/Swifter.xcodeproj/project.xcworkspace/contents.xcworkspacedata (100%) rename {XCode => Xcode}/Swifter.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist (100%) rename {XCode => Xcode}/Swifter.xcodeproj/xcshareddata/xcschemes/SwifterMac.xcscheme (100%) rename {XCode => Xcode}/Swifter.xcodeproj/xcshareddata/xcschemes/SwifterSampleOSX.xcscheme (100%) rename {XCode => Xcode}/Swifter.xcodeproj/xcshareddata/xcschemes/SwifteriOS.xcscheme (100%) rename {XCode => Xcode}/Swifter.xcodeproj/xcshareddata/xcschemes/SwifteriOSTests.xcscheme (100%) rename {XCode => Xcode}/Swifter.xcodeproj/xcshareddata/xcschemes/SwiftermacOSTests.xcscheme (100%) rename {XCode => Xcode}/Swifter.xcodeproj/xcshareddata/xcschemes/SwiftertvOS.xcscheme (100%) rename {XCode => Xcode}/Swifter.xcodeproj/xcshareddata/xcschemes/SwiftertvOSTests.xcscheme (100%) rename {XCode => Xcode}/SwifterMac/Info.plist (100%) rename {XCode => Xcode}/SwifterMac/SwifterMac.h (100%) rename {XCode => Xcode}/SwifterSampleOSX/main.swift (100%) rename {XCode => Xcode}/SwifterSampleiOS/AppDelegate.swift (100%) rename {XCode => Xcode}/SwifterSampleiOS/Base.lproj/Main.storyboard (100%) rename {XCode => Xcode}/SwifterSampleiOS/Images.xcassets/AppIcon.appiconset/Contents.json (100%) rename {XCode => Xcode}/SwifterSampleiOS/Images.xcassets/LaunchImage.launchimage/Contents.json (100%) rename {XCode => Xcode}/SwifterSampleiOS/Info.plist (100%) rename {XCode => Xcode}/SwifterSampleiOS/Launch Screen.storyboard (100%) rename {XCode => Xcode}/SwifterSampleiOS/ViewController.swift (100%) rename {XCode => Xcode}/SwifteriOS/Info.plist (100%) rename {XCode => Xcode}/SwifteriOS/SwifteriOS.h (100%) rename {XCode => Xcode}/SwifteriOSTests/Info.plist (100%) rename {XCode => Xcode}/SwiftermacOSTests/Info.plist (100%) rename {XCode => Xcode}/SwiftertvOS/Info.plist (100%) rename {XCode => Xcode}/SwiftertvOS/SwiftertvOS.h (100%) rename {XCode => Xcode}/SwiftertvOSTests/Info.plist (100%) rename {XCode => Xcode}/Tests/IOSafetyTests.swift (100%) rename {XCode => Xcode}/Tests/MimeTypesTests.swift (100%) rename {XCode => Xcode}/Tests/PingServer.swift (100%) rename {XCode => Xcode}/Tests/ServerThreadingTests.swift (100%) rename {XCode => Xcode}/Tests/SwifterTestsHttpParser.swift (100%) rename {XCode => Xcode}/Tests/SwifterTestsHttpResponseBody.swift (100%) rename {XCode => Xcode}/Tests/SwifterTestsHttpRouter.swift (100%) rename {XCode => Xcode}/Tests/SwifterTestsStringExtensions.swift (100%) rename {XCode => Xcode}/Tests/SwifterTestsWebSocketSession.swift (100%) rename {XCode => Xcode}/Tests/XCTestManifests.swift (100%) diff --git a/XCode/LinuxMain.swift b/Xcode/LinuxMain.swift similarity index 100% rename from XCode/LinuxMain.swift rename to Xcode/LinuxMain.swift diff --git a/XCode/Resources/logo.png b/Xcode/Resources/logo.png similarity index 100% rename from XCode/Resources/logo.png rename to Xcode/Resources/logo.png diff --git a/XCode/Sources/DemoServer.swift b/Xcode/Sources/DemoServer.swift similarity index 100% rename from XCode/Sources/DemoServer.swift rename to Xcode/Sources/DemoServer.swift diff --git a/XCode/Sources/Errno.swift b/Xcode/Sources/Errno.swift similarity index 100% rename from XCode/Sources/Errno.swift rename to Xcode/Sources/Errno.swift diff --git a/XCode/Sources/Files.swift b/Xcode/Sources/Files.swift similarity index 100% rename from XCode/Sources/Files.swift rename to Xcode/Sources/Files.swift diff --git a/XCode/Sources/HttpParser.swift b/Xcode/Sources/HttpParser.swift similarity index 100% rename from XCode/Sources/HttpParser.swift rename to Xcode/Sources/HttpParser.swift diff --git a/XCode/Sources/HttpRequest.swift b/Xcode/Sources/HttpRequest.swift similarity index 100% rename from XCode/Sources/HttpRequest.swift rename to Xcode/Sources/HttpRequest.swift diff --git a/XCode/Sources/HttpResponse.swift b/Xcode/Sources/HttpResponse.swift similarity index 100% rename from XCode/Sources/HttpResponse.swift rename to Xcode/Sources/HttpResponse.swift diff --git a/XCode/Sources/HttpRouter.swift b/Xcode/Sources/HttpRouter.swift similarity index 100% rename from XCode/Sources/HttpRouter.swift rename to Xcode/Sources/HttpRouter.swift diff --git a/XCode/Sources/HttpServer.swift b/Xcode/Sources/HttpServer.swift similarity index 100% rename from XCode/Sources/HttpServer.swift rename to Xcode/Sources/HttpServer.swift diff --git a/XCode/Sources/HttpServerIO.swift b/Xcode/Sources/HttpServerIO.swift similarity index 100% rename from XCode/Sources/HttpServerIO.swift rename to Xcode/Sources/HttpServerIO.swift diff --git a/XCode/Sources/MimeTypes.swift b/Xcode/Sources/MimeTypes.swift similarity index 100% rename from XCode/Sources/MimeTypes.swift rename to Xcode/Sources/MimeTypes.swift diff --git a/XCode/Sources/Process.swift b/Xcode/Sources/Process.swift similarity index 100% rename from XCode/Sources/Process.swift rename to Xcode/Sources/Process.swift diff --git a/XCode/Sources/Scopes.swift b/Xcode/Sources/Scopes.swift similarity index 100% rename from XCode/Sources/Scopes.swift rename to Xcode/Sources/Scopes.swift diff --git a/XCode/Sources/Socket+File.swift b/Xcode/Sources/Socket+File.swift similarity index 100% rename from XCode/Sources/Socket+File.swift rename to Xcode/Sources/Socket+File.swift diff --git a/XCode/Sources/Socket+Server.swift b/Xcode/Sources/Socket+Server.swift similarity index 100% rename from XCode/Sources/Socket+Server.swift rename to Xcode/Sources/Socket+Server.swift diff --git a/XCode/Sources/Socket.swift b/Xcode/Sources/Socket.swift similarity index 100% rename from XCode/Sources/Socket.swift rename to Xcode/Sources/Socket.swift diff --git a/XCode/Sources/String+BASE64.swift b/Xcode/Sources/String+BASE64.swift similarity index 100% rename from XCode/Sources/String+BASE64.swift rename to Xcode/Sources/String+BASE64.swift diff --git a/XCode/Sources/String+File.swift b/Xcode/Sources/String+File.swift similarity index 100% rename from XCode/Sources/String+File.swift rename to Xcode/Sources/String+File.swift diff --git a/XCode/Sources/String+Misc.swift b/Xcode/Sources/String+Misc.swift similarity index 100% rename from XCode/Sources/String+Misc.swift rename to Xcode/Sources/String+Misc.swift diff --git a/XCode/Sources/String+SHA1.swift b/Xcode/Sources/String+SHA1.swift similarity index 100% rename from XCode/Sources/String+SHA1.swift rename to Xcode/Sources/String+SHA1.swift diff --git a/XCode/Sources/WebSockets.swift b/Xcode/Sources/WebSockets.swift similarity index 100% rename from XCode/Sources/WebSockets.swift rename to Xcode/Sources/WebSockets.swift diff --git a/XCode/Swifter.xcodeproj/project.pbxproj b/Xcode/Swifter.xcodeproj/project.pbxproj similarity index 100% rename from XCode/Swifter.xcodeproj/project.pbxproj rename to Xcode/Swifter.xcodeproj/project.pbxproj diff --git a/XCode/Swifter.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/Xcode/Swifter.xcodeproj/project.xcworkspace/contents.xcworkspacedata similarity index 100% rename from XCode/Swifter.xcodeproj/project.xcworkspace/contents.xcworkspacedata rename to Xcode/Swifter.xcodeproj/project.xcworkspace/contents.xcworkspacedata diff --git a/XCode/Swifter.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/Xcode/Swifter.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist similarity index 100% rename from XCode/Swifter.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist rename to Xcode/Swifter.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist diff --git a/XCode/Swifter.xcodeproj/xcshareddata/xcschemes/SwifterMac.xcscheme b/Xcode/Swifter.xcodeproj/xcshareddata/xcschemes/SwifterMac.xcscheme similarity index 100% rename from XCode/Swifter.xcodeproj/xcshareddata/xcschemes/SwifterMac.xcscheme rename to Xcode/Swifter.xcodeproj/xcshareddata/xcschemes/SwifterMac.xcscheme diff --git a/XCode/Swifter.xcodeproj/xcshareddata/xcschemes/SwifterSampleOSX.xcscheme b/Xcode/Swifter.xcodeproj/xcshareddata/xcschemes/SwifterSampleOSX.xcscheme similarity index 100% rename from XCode/Swifter.xcodeproj/xcshareddata/xcschemes/SwifterSampleOSX.xcscheme rename to Xcode/Swifter.xcodeproj/xcshareddata/xcschemes/SwifterSampleOSX.xcscheme diff --git a/XCode/Swifter.xcodeproj/xcshareddata/xcschemes/SwifteriOS.xcscheme b/Xcode/Swifter.xcodeproj/xcshareddata/xcschemes/SwifteriOS.xcscheme similarity index 100% rename from XCode/Swifter.xcodeproj/xcshareddata/xcschemes/SwifteriOS.xcscheme rename to Xcode/Swifter.xcodeproj/xcshareddata/xcschemes/SwifteriOS.xcscheme diff --git a/XCode/Swifter.xcodeproj/xcshareddata/xcschemes/SwifteriOSTests.xcscheme b/Xcode/Swifter.xcodeproj/xcshareddata/xcschemes/SwifteriOSTests.xcscheme similarity index 100% rename from XCode/Swifter.xcodeproj/xcshareddata/xcschemes/SwifteriOSTests.xcscheme rename to Xcode/Swifter.xcodeproj/xcshareddata/xcschemes/SwifteriOSTests.xcscheme diff --git a/XCode/Swifter.xcodeproj/xcshareddata/xcschemes/SwiftermacOSTests.xcscheme b/Xcode/Swifter.xcodeproj/xcshareddata/xcschemes/SwiftermacOSTests.xcscheme similarity index 100% rename from XCode/Swifter.xcodeproj/xcshareddata/xcschemes/SwiftermacOSTests.xcscheme rename to Xcode/Swifter.xcodeproj/xcshareddata/xcschemes/SwiftermacOSTests.xcscheme diff --git a/XCode/Swifter.xcodeproj/xcshareddata/xcschemes/SwiftertvOS.xcscheme b/Xcode/Swifter.xcodeproj/xcshareddata/xcschemes/SwiftertvOS.xcscheme similarity index 100% rename from XCode/Swifter.xcodeproj/xcshareddata/xcschemes/SwiftertvOS.xcscheme rename to Xcode/Swifter.xcodeproj/xcshareddata/xcschemes/SwiftertvOS.xcscheme diff --git a/XCode/Swifter.xcodeproj/xcshareddata/xcschemes/SwiftertvOSTests.xcscheme b/Xcode/Swifter.xcodeproj/xcshareddata/xcschemes/SwiftertvOSTests.xcscheme similarity index 100% rename from XCode/Swifter.xcodeproj/xcshareddata/xcschemes/SwiftertvOSTests.xcscheme rename to Xcode/Swifter.xcodeproj/xcshareddata/xcschemes/SwiftertvOSTests.xcscheme diff --git a/XCode/SwifterMac/Info.plist b/Xcode/SwifterMac/Info.plist similarity index 100% rename from XCode/SwifterMac/Info.plist rename to Xcode/SwifterMac/Info.plist diff --git a/XCode/SwifterMac/SwifterMac.h b/Xcode/SwifterMac/SwifterMac.h similarity index 100% rename from XCode/SwifterMac/SwifterMac.h rename to Xcode/SwifterMac/SwifterMac.h diff --git a/XCode/SwifterSampleOSX/main.swift b/Xcode/SwifterSampleOSX/main.swift similarity index 100% rename from XCode/SwifterSampleOSX/main.swift rename to Xcode/SwifterSampleOSX/main.swift diff --git a/XCode/SwifterSampleiOS/AppDelegate.swift b/Xcode/SwifterSampleiOS/AppDelegate.swift similarity index 100% rename from XCode/SwifterSampleiOS/AppDelegate.swift rename to Xcode/SwifterSampleiOS/AppDelegate.swift diff --git a/XCode/SwifterSampleiOS/Base.lproj/Main.storyboard b/Xcode/SwifterSampleiOS/Base.lproj/Main.storyboard similarity index 100% rename from XCode/SwifterSampleiOS/Base.lproj/Main.storyboard rename to Xcode/SwifterSampleiOS/Base.lproj/Main.storyboard diff --git a/XCode/SwifterSampleiOS/Images.xcassets/AppIcon.appiconset/Contents.json b/Xcode/SwifterSampleiOS/Images.xcassets/AppIcon.appiconset/Contents.json similarity index 100% rename from XCode/SwifterSampleiOS/Images.xcassets/AppIcon.appiconset/Contents.json rename to Xcode/SwifterSampleiOS/Images.xcassets/AppIcon.appiconset/Contents.json diff --git a/XCode/SwifterSampleiOS/Images.xcassets/LaunchImage.launchimage/Contents.json b/Xcode/SwifterSampleiOS/Images.xcassets/LaunchImage.launchimage/Contents.json similarity index 100% rename from XCode/SwifterSampleiOS/Images.xcassets/LaunchImage.launchimage/Contents.json rename to Xcode/SwifterSampleiOS/Images.xcassets/LaunchImage.launchimage/Contents.json diff --git a/XCode/SwifterSampleiOS/Info.plist b/Xcode/SwifterSampleiOS/Info.plist similarity index 100% rename from XCode/SwifterSampleiOS/Info.plist rename to Xcode/SwifterSampleiOS/Info.plist diff --git a/XCode/SwifterSampleiOS/Launch Screen.storyboard b/Xcode/SwifterSampleiOS/Launch Screen.storyboard similarity index 100% rename from XCode/SwifterSampleiOS/Launch Screen.storyboard rename to Xcode/SwifterSampleiOS/Launch Screen.storyboard diff --git a/XCode/SwifterSampleiOS/ViewController.swift b/Xcode/SwifterSampleiOS/ViewController.swift similarity index 100% rename from XCode/SwifterSampleiOS/ViewController.swift rename to Xcode/SwifterSampleiOS/ViewController.swift diff --git a/XCode/SwifteriOS/Info.plist b/Xcode/SwifteriOS/Info.plist similarity index 100% rename from XCode/SwifteriOS/Info.plist rename to Xcode/SwifteriOS/Info.plist diff --git a/XCode/SwifteriOS/SwifteriOS.h b/Xcode/SwifteriOS/SwifteriOS.h similarity index 100% rename from XCode/SwifteriOS/SwifteriOS.h rename to Xcode/SwifteriOS/SwifteriOS.h diff --git a/XCode/SwifteriOSTests/Info.plist b/Xcode/SwifteriOSTests/Info.plist similarity index 100% rename from XCode/SwifteriOSTests/Info.plist rename to Xcode/SwifteriOSTests/Info.plist diff --git a/XCode/SwiftermacOSTests/Info.plist b/Xcode/SwiftermacOSTests/Info.plist similarity index 100% rename from XCode/SwiftermacOSTests/Info.plist rename to Xcode/SwiftermacOSTests/Info.plist diff --git a/XCode/SwiftertvOS/Info.plist b/Xcode/SwiftertvOS/Info.plist similarity index 100% rename from XCode/SwiftertvOS/Info.plist rename to Xcode/SwiftertvOS/Info.plist diff --git a/XCode/SwiftertvOS/SwiftertvOS.h b/Xcode/SwiftertvOS/SwiftertvOS.h similarity index 100% rename from XCode/SwiftertvOS/SwiftertvOS.h rename to Xcode/SwiftertvOS/SwiftertvOS.h diff --git a/XCode/SwiftertvOSTests/Info.plist b/Xcode/SwiftertvOSTests/Info.plist similarity index 100% rename from XCode/SwiftertvOSTests/Info.plist rename to Xcode/SwiftertvOSTests/Info.plist diff --git a/XCode/Tests/IOSafetyTests.swift b/Xcode/Tests/IOSafetyTests.swift similarity index 100% rename from XCode/Tests/IOSafetyTests.swift rename to Xcode/Tests/IOSafetyTests.swift diff --git a/XCode/Tests/MimeTypesTests.swift b/Xcode/Tests/MimeTypesTests.swift similarity index 100% rename from XCode/Tests/MimeTypesTests.swift rename to Xcode/Tests/MimeTypesTests.swift diff --git a/XCode/Tests/PingServer.swift b/Xcode/Tests/PingServer.swift similarity index 100% rename from XCode/Tests/PingServer.swift rename to Xcode/Tests/PingServer.swift diff --git a/XCode/Tests/ServerThreadingTests.swift b/Xcode/Tests/ServerThreadingTests.swift similarity index 100% rename from XCode/Tests/ServerThreadingTests.swift rename to Xcode/Tests/ServerThreadingTests.swift diff --git a/XCode/Tests/SwifterTestsHttpParser.swift b/Xcode/Tests/SwifterTestsHttpParser.swift similarity index 100% rename from XCode/Tests/SwifterTestsHttpParser.swift rename to Xcode/Tests/SwifterTestsHttpParser.swift diff --git a/XCode/Tests/SwifterTestsHttpResponseBody.swift b/Xcode/Tests/SwifterTestsHttpResponseBody.swift similarity index 100% rename from XCode/Tests/SwifterTestsHttpResponseBody.swift rename to Xcode/Tests/SwifterTestsHttpResponseBody.swift diff --git a/XCode/Tests/SwifterTestsHttpRouter.swift b/Xcode/Tests/SwifterTestsHttpRouter.swift similarity index 100% rename from XCode/Tests/SwifterTestsHttpRouter.swift rename to Xcode/Tests/SwifterTestsHttpRouter.swift diff --git a/XCode/Tests/SwifterTestsStringExtensions.swift b/Xcode/Tests/SwifterTestsStringExtensions.swift similarity index 100% rename from XCode/Tests/SwifterTestsStringExtensions.swift rename to Xcode/Tests/SwifterTestsStringExtensions.swift diff --git a/XCode/Tests/SwifterTestsWebSocketSession.swift b/Xcode/Tests/SwifterTestsWebSocketSession.swift similarity index 100% rename from XCode/Tests/SwifterTestsWebSocketSession.swift rename to Xcode/Tests/SwifterTestsWebSocketSession.swift diff --git a/XCode/Tests/XCTestManifests.swift b/Xcode/Tests/XCTestManifests.swift similarity index 100% rename from XCode/Tests/XCTestManifests.swift rename to Xcode/Tests/XCTestManifests.swift From 9e461c64754d1baf611e75c3d203e98ebe856451 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 13 Jul 2021 02:52:34 +0000 Subject: [PATCH 14/28] Bump addressable from 2.7.0 to 2.8.0 Bumps [addressable](https://github.com/sporkmonger/addressable) from 2.7.0 to 2.8.0. - [Release notes](https://github.com/sporkmonger/addressable/releases) - [Changelog](https://github.com/sporkmonger/addressable/blob/main/CHANGELOG.md) - [Commits](https://github.com/sporkmonger/addressable/compare/addressable-2.7.0...addressable-2.8.0) --- updated-dependencies: - dependency-name: addressable dependency-type: indirect ... Signed-off-by: dependabot[bot] --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index 056e8b4a..4fdd9b46 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ GEM remote: https://rubygems.org/ specs: - addressable (2.7.0) + addressable (2.8.0) public_suffix (>= 2.0.2, < 5.0) claide (1.0.3) claide-plugins (0.9.2) From b592bf155e7c37343423fbf269c846df66140061 Mon Sep 17 00:00:00 2001 From: Jim Crate Date: Mon, 2 Aug 2021 15:00:39 -0400 Subject: [PATCH 15/28] Update Files.swift Sharing a file now sets content type and length --- Xcode/Sources/Files.swift | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Xcode/Sources/Files.swift b/Xcode/Sources/Files.swift index f778975a..1905e6bb 100644 --- a/Xcode/Sources/Files.swift +++ b/Xcode/Sources/Files.swift @@ -10,7 +10,14 @@ import Foundation public func shareFile(_ path: String) -> ((HttpRequest) -> HttpResponse) { return { _ in if let file = try? path.openForReading() { - return .raw(200, "OK", [:], { writer in + let mimeType = path.mimeType() + var responseHeader: [String: String] = ["Content-Type": mimeType] + + if let attr = try? FileManager.default.attributesOfItem(atPath: path), + let fileSize = attr[FileAttributeKey.size] as? UInt64 { + responseHeader["Content-Length"] = String(fileSize) + } + return .raw(200, "OK", responseHeader, { writer in try? writer.write(file) file.close() }) From 8ee4eb8b0ebdce243d6c84c0e311cb6c6261a72f Mon Sep 17 00:00:00 2001 From: Yuri Goncharov Date: Wed, 1 Sep 2021 15:27:08 +0300 Subject: [PATCH 16/28] added custom headers into .ok response --- Xcode/Sources/DemoServer.swift | 10 +++++----- Xcode/Sources/HttpResponse.swift | 9 ++++++--- Xcode/Tests/PingServer.swift | 2 +- Xcode/Tests/ServerThreadingTests.swift | 4 ++-- Xcode/Tests/SwifterTestsHttpRouter.swift | 18 +++++++++--------- 5 files changed, 23 insertions(+), 20 deletions(-) diff --git a/Xcode/Sources/DemoServer.swift b/Xcode/Sources/DemoServer.swift index 51fd73cf..49582147 100644 --- a/Xcode/Sources/DemoServer.swift +++ b/Xcode/Sources/DemoServer.swift @@ -30,7 +30,7 @@ public func demoServer(_ publicDir: String) -> HttpServer { } } - server["/magic"] = { .ok(.htmlBody("You asked for " + $0.path)) } + server["/magic"] = { .ok(.htmlBody("You asked for " + $0.path), ["XXX-Custom-Header": "value"]) } server["/test/:param1/:param2"] = { request in scopes { @@ -98,7 +98,7 @@ public func demoServer(_ publicDir: String) -> HttpServer { guard let name = multipart.name, let fileName = multipart.fileName else { continue } response += "Name: \(name) File name: \(fileName) Size: \(multipart.body.count)
" } - return HttpResponse.ok(.htmlBody(response)) + return HttpResponse.ok(.htmlBody(response), ["XXX-Custom-Header": "value"]) } server.GET["/login"] = scopes { @@ -136,7 +136,7 @@ public func demoServer(_ publicDir: String) -> HttpServer { server.POST["/login"] = { request in let formFields = request.parseUrlencodedForm() - return HttpResponse.ok(.htmlBody(formFields.map({ "\($0.0) = \($0.1)" }).joined(separator: "
"))) + return HttpResponse.ok(.htmlBody(formFields.map({ "\($0.0) = \($0.1)" }).joined(separator: "
")), ["XXX-Custom-Header": "value"]) } server["/demo"] = scopes { @@ -165,11 +165,11 @@ public func demoServer(_ publicDir: String) -> HttpServer { server["/long"] = { _ in var longResponse = "" for index in 0..<1000 { longResponse += "(\(index)),->" } - return .ok(.htmlBody(longResponse)) + return .ok(.htmlBody(longResponse), ["XXX-Custom-Header": "value"]) } server["/wildcard/*/test/*/:param"] = { request in - return .ok(.htmlBody(request.path)) + return .ok(.htmlBody(request.path), ["XXX-Custom-Header": "value"]) } server["/stream"] = { _ in diff --git a/Xcode/Sources/HttpResponse.swift b/Xcode/Sources/HttpResponse.swift index 7963dc75..99ba1ee6 100644 --- a/Xcode/Sources/HttpResponse.swift +++ b/Xcode/Sources/HttpResponse.swift @@ -80,7 +80,7 @@ public enum HttpResponseBody { public enum HttpResponse { case switchProtocols([String: String], (Socket) -> Void) - case ok(HttpResponseBody), created, accepted + case ok(HttpResponseBody, [String: String]), created, accepted case movedPermanently(String) case movedTemporarily(String) case badRequest(HttpResponseBody?), unauthorized, forbidden, notFound, notAcceptable @@ -133,7 +133,10 @@ public enum HttpResponse { for (key, value) in switchHeaders { headers[key] = value } - case .ok(let body): + case .ok(let body, let customHeaders): + for (key, value) in customHeaders { + headers.updateValue(value, forKey: key) + } switch body { case .json: headers["Content-Type"] = "application/json" case .html, .htmlBody: headers["Content-Type"] = "text/html" @@ -158,7 +161,7 @@ public enum HttpResponse { func content() -> (length: Int, write: ((HttpResponseBodyWriter) throws -> Void)?) { switch self { - case .ok(let body) : return body.content() + case .ok(let body, _) : return body.content() case .badRequest(let body) : return body?.content() ?? (-1, nil) case .raw(_, _, _, let writer) : return (-1, writer) default : return (-1, nil) diff --git a/Xcode/Tests/PingServer.swift b/Xcode/Tests/PingServer.swift index eb7fe124..6e23ed04 100644 --- a/Xcode/Tests/PingServer.swift +++ b/Xcode/Tests/PingServer.swift @@ -17,7 +17,7 @@ extension HttpServer { class func pingServer() -> HttpServer { let server = HttpServer() server.GET["/ping"] = { request in - return HttpResponse.ok(.text("pong!")) + return HttpResponse.ok(.text("pong!"), [:]) } return server } diff --git a/Xcode/Tests/ServerThreadingTests.swift b/Xcode/Tests/ServerThreadingTests.swift index 640df2ae..bdfa3f98 100644 --- a/Xcode/Tests/ServerThreadingTests.swift +++ b/Xcode/Tests/ServerThreadingTests.swift @@ -35,7 +35,7 @@ class ServerThreadingTests: XCTestCase { let queue = DispatchQueue(label: "com.swifter.threading") let hostURL: URL - server.GET[path] = { .ok(.htmlBody("You asked for " + $0.path)) } + server.GET[path] = { .ok(.htmlBody("You asked for " + $0.path), [:]) } do { @@ -73,7 +73,7 @@ class ServerThreadingTests: XCTestCase { func testShouldHandleTheSameRequestConcurrently() { let path = "/a/:b/c" - server.GET[path] = { .ok(.htmlBody("You asked for " + $0.path)) } + server.GET[path] = { .ok(.htmlBody("You asked for " + $0.path), [:]) } var requestExpectation: XCTestExpectation? = expectation(description: "Should handle the request concurrently") diff --git a/Xcode/Tests/SwifterTestsHttpRouter.swift b/Xcode/Tests/SwifterTestsHttpRouter.swift index c4b06df5..38de0ec2 100644 --- a/Xcode/Tests/SwifterTestsHttpRouter.swift +++ b/Xcode/Tests/SwifterTestsHttpRouter.swift @@ -26,7 +26,7 @@ class SwifterTestsHttpRouter: XCTestCase { func testHttpRouterSlashRoot() { router.register(nil, path: "/", handler: { _ in - return .ok(.htmlBody("OK")) + return .ok(.htmlBody("OK"), [:]) }) XCTAssertNotNil(router.route(nil, path: "/")) @@ -35,7 +35,7 @@ class SwifterTestsHttpRouter: XCTestCase { func testHttpRouterSimplePathSegments() { router.register(nil, path: "/a/b/c/d", handler: { _ in - return .ok(.htmlBody("OK")) + return .ok(.htmlBody("OK"), [:]) }) XCTAssertNil(router.route(nil, path: "/")) @@ -48,7 +48,7 @@ class SwifterTestsHttpRouter: XCTestCase { func testHttpRouterSinglePathSegmentWildcard() { router.register(nil, path: "/a/*/c/d", handler: { _ in - return .ok(.htmlBody("OK")) + return .ok(.htmlBody("OK"), [:]) }) XCTAssertNil(router.route(nil, path: "/")) @@ -62,7 +62,7 @@ class SwifterTestsHttpRouter: XCTestCase { func testHttpRouterVariables() { router.register(nil, path: "/a/:arg1/:arg2/b/c/d/:arg3", handler: { _ in - return .ok(.htmlBody("OK")) + return .ok(.htmlBody("OK"), [:]) }) XCTAssertNil(router.route(nil, path: "/")) @@ -76,7 +76,7 @@ class SwifterTestsHttpRouter: XCTestCase { func testHttpRouterMultiplePathSegmentWildcards() { router.register(nil, path: "/a/**/e/f/g", handler: { _ in - return .ok(.htmlBody("OK")) + return .ok(.htmlBody("OK"), [:]) }) XCTAssertNil(router.route(nil, path: "/")) @@ -88,7 +88,7 @@ class SwifterTestsHttpRouter: XCTestCase { func testHttpRouterMultiplePathSegmentWildcardTail() { router.register(nil, path: "/a/b/**", handler: { _ in - return .ok(.htmlBody("OK")) + return .ok(.htmlBody("OK"), [:]) }) XCTAssertNil(router.route(nil, path: "/")) @@ -100,11 +100,11 @@ class SwifterTestsHttpRouter: XCTestCase { func testHttpRouterEmptyTail() { router.register(nil, path: "/a/b/", handler: { _ in - return .ok(.htmlBody("OK")) + return .ok(.htmlBody("OK"), [:]) }) router.register(nil, path: "/a/b/:var", handler: { _ in - return .ok(.htmlBody("OK")) + return .ok(.htmlBody("OK"), [:]) }) XCTAssertNil(router.route(nil, path: "/")) @@ -120,7 +120,7 @@ class SwifterTestsHttpRouter: XCTestCase { func testHttpRouterPercentEncodedPathSegments() { router.register(nil, path: "/a/<>/^", handler: { _ in - return .ok(.htmlBody("OK")) + return .ok(.htmlBody("OK"), [:]) }) XCTAssertNil(router.route(nil, path: "/")) From 685855f6cddd0b98b66c56deea69746d4901aeb7 Mon Sep 17 00:00:00 2001 From: Yuri Goncharov Date: Fri, 3 Sep 2021 14:36:39 +0300 Subject: [PATCH 17/28] added default value for custom headers --- Xcode/Sources/HttpResponse.swift | 2 +- Xcode/Tests/PingServer.swift | 2 +- Xcode/Tests/ServerThreadingTests.swift | 4 ++-- Xcode/Tests/SwifterTestsHttpRouter.swift | 18 +++++++++--------- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/Xcode/Sources/HttpResponse.swift b/Xcode/Sources/HttpResponse.swift index 99ba1ee6..56dc4a0b 100644 --- a/Xcode/Sources/HttpResponse.swift +++ b/Xcode/Sources/HttpResponse.swift @@ -80,7 +80,7 @@ public enum HttpResponseBody { public enum HttpResponse { case switchProtocols([String: String], (Socket) -> Void) - case ok(HttpResponseBody, [String: String]), created, accepted + case ok(HttpResponseBody, [String: String] = [:]), created, accepted case movedPermanently(String) case movedTemporarily(String) case badRequest(HttpResponseBody?), unauthorized, forbidden, notFound, notAcceptable diff --git a/Xcode/Tests/PingServer.swift b/Xcode/Tests/PingServer.swift index 6e23ed04..eb7fe124 100644 --- a/Xcode/Tests/PingServer.swift +++ b/Xcode/Tests/PingServer.swift @@ -17,7 +17,7 @@ extension HttpServer { class func pingServer() -> HttpServer { let server = HttpServer() server.GET["/ping"] = { request in - return HttpResponse.ok(.text("pong!"), [:]) + return HttpResponse.ok(.text("pong!")) } return server } diff --git a/Xcode/Tests/ServerThreadingTests.swift b/Xcode/Tests/ServerThreadingTests.swift index bdfa3f98..640df2ae 100644 --- a/Xcode/Tests/ServerThreadingTests.swift +++ b/Xcode/Tests/ServerThreadingTests.swift @@ -35,7 +35,7 @@ class ServerThreadingTests: XCTestCase { let queue = DispatchQueue(label: "com.swifter.threading") let hostURL: URL - server.GET[path] = { .ok(.htmlBody("You asked for " + $0.path), [:]) } + server.GET[path] = { .ok(.htmlBody("You asked for " + $0.path)) } do { @@ -73,7 +73,7 @@ class ServerThreadingTests: XCTestCase { func testShouldHandleTheSameRequestConcurrently() { let path = "/a/:b/c" - server.GET[path] = { .ok(.htmlBody("You asked for " + $0.path), [:]) } + server.GET[path] = { .ok(.htmlBody("You asked for " + $0.path)) } var requestExpectation: XCTestExpectation? = expectation(description: "Should handle the request concurrently") diff --git a/Xcode/Tests/SwifterTestsHttpRouter.swift b/Xcode/Tests/SwifterTestsHttpRouter.swift index 38de0ec2..c4b06df5 100644 --- a/Xcode/Tests/SwifterTestsHttpRouter.swift +++ b/Xcode/Tests/SwifterTestsHttpRouter.swift @@ -26,7 +26,7 @@ class SwifterTestsHttpRouter: XCTestCase { func testHttpRouterSlashRoot() { router.register(nil, path: "/", handler: { _ in - return .ok(.htmlBody("OK"), [:]) + return .ok(.htmlBody("OK")) }) XCTAssertNotNil(router.route(nil, path: "/")) @@ -35,7 +35,7 @@ class SwifterTestsHttpRouter: XCTestCase { func testHttpRouterSimplePathSegments() { router.register(nil, path: "/a/b/c/d", handler: { _ in - return .ok(.htmlBody("OK"), [:]) + return .ok(.htmlBody("OK")) }) XCTAssertNil(router.route(nil, path: "/")) @@ -48,7 +48,7 @@ class SwifterTestsHttpRouter: XCTestCase { func testHttpRouterSinglePathSegmentWildcard() { router.register(nil, path: "/a/*/c/d", handler: { _ in - return .ok(.htmlBody("OK"), [:]) + return .ok(.htmlBody("OK")) }) XCTAssertNil(router.route(nil, path: "/")) @@ -62,7 +62,7 @@ class SwifterTestsHttpRouter: XCTestCase { func testHttpRouterVariables() { router.register(nil, path: "/a/:arg1/:arg2/b/c/d/:arg3", handler: { _ in - return .ok(.htmlBody("OK"), [:]) + return .ok(.htmlBody("OK")) }) XCTAssertNil(router.route(nil, path: "/")) @@ -76,7 +76,7 @@ class SwifterTestsHttpRouter: XCTestCase { func testHttpRouterMultiplePathSegmentWildcards() { router.register(nil, path: "/a/**/e/f/g", handler: { _ in - return .ok(.htmlBody("OK"), [:]) + return .ok(.htmlBody("OK")) }) XCTAssertNil(router.route(nil, path: "/")) @@ -88,7 +88,7 @@ class SwifterTestsHttpRouter: XCTestCase { func testHttpRouterMultiplePathSegmentWildcardTail() { router.register(nil, path: "/a/b/**", handler: { _ in - return .ok(.htmlBody("OK"), [:]) + return .ok(.htmlBody("OK")) }) XCTAssertNil(router.route(nil, path: "/")) @@ -100,11 +100,11 @@ class SwifterTestsHttpRouter: XCTestCase { func testHttpRouterEmptyTail() { router.register(nil, path: "/a/b/", handler: { _ in - return .ok(.htmlBody("OK"), [:]) + return .ok(.htmlBody("OK")) }) router.register(nil, path: "/a/b/:var", handler: { _ in - return .ok(.htmlBody("OK"), [:]) + return .ok(.htmlBody("OK")) }) XCTAssertNil(router.route(nil, path: "/")) @@ -120,7 +120,7 @@ class SwifterTestsHttpRouter: XCTestCase { func testHttpRouterPercentEncodedPathSegments() { router.register(nil, path: "/a/<>/^", handler: { _ in - return .ok(.htmlBody("OK"), [:]) + return .ok(.htmlBody("OK")) }) XCTAssertNil(router.route(nil, path: "/")) From f66fd8a46d505e69b12bb65fbc5f38282568387d Mon Sep 17 00:00:00 2001 From: Yuri Goncharov Date: Mon, 6 Sep 2021 11:52:05 +0300 Subject: [PATCH 18/28] removed spaces --- Xcode/Sources/HttpResponse.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Xcode/Sources/HttpResponse.swift b/Xcode/Sources/HttpResponse.swift index 56dc4a0b..9d50ed65 100644 --- a/Xcode/Sources/HttpResponse.swift +++ b/Xcode/Sources/HttpResponse.swift @@ -161,7 +161,7 @@ public enum HttpResponse { func content() -> (length: Int, write: ((HttpResponseBodyWriter) throws -> Void)?) { switch self { - case .ok(let body, _) : return body.content() + case .ok(let body, _) : return body.content() case .badRequest(let body) : return body?.content() ?? (-1, nil) case .raw(_, _, _, let writer) : return (-1, writer) default : return (-1, nil) From d998bf5358d8294bb982ae474160c53e42dbde0c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Fo=C5=99t?= Date: Sun, 12 Sep 2021 14:13:20 +0200 Subject: [PATCH 19/28] Rename Example to SwifterExample (#492) * Rename Example to SwifterExample * Update CHANGELOG --- CHANGELOG.md | 4 ++++ Package.swift | 9 +++++---- {Example => SwifterExample}/main.swift | 0 3 files changed, 9 insertions(+), 4 deletions(-) rename {Example => SwifterExample}/main.swift (100%) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0c1a3323..b149c893 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -27,6 +27,10 @@ All notable changes to this project will be documented in this file. Changes not * Fix misspell `serialise`. ([#473](https://github.com/httpswift/swifter/pull/473)) by [@mtgto](https://github.com/mtgto) * Fix an issue causing Danger was not working properly. ([#486](https://github.com/httpswift/swifter/pull/486)) by [@Vkt0r](https://github.com/Vkt0r) +## Changed + +- Rename `Example` product to `SwifterExample` ([#492](https://github.com/httpswift/swifter/pull/492) by [@fortmarek](https://github.com/fortmarek)) + # [1.5.0] ## Added diff --git a/Package.swift b/Package.swift index b8b72e32..66fde6e1 100644 --- a/Package.swift +++ b/Package.swift @@ -7,7 +7,7 @@ let package = Package( products: [ .library(name: "Swifter", targets: ["Swifter"]), - .executable(name: "Example", targets: ["Example"]) + .executable(name: "SwifterExample", targets: ["SwifterExample"]) ], dependencies: [], @@ -20,11 +20,12 @@ let package = Package( ), .target( - name: "Example", + name: "SwifterExample", dependencies: [ "Swifter" ], - path: "Example"), + path: "SwifterExample" + ), .testTarget( name: "SwifterTests", @@ -34,4 +35,4 @@ let package = Package( path: "Xcode/Tests" ) ] -) \ No newline at end of file +) diff --git a/Example/main.swift b/SwifterExample/main.swift similarity index 100% rename from Example/main.swift rename to SwifterExample/main.swift From 01e44211fa98d2f9209f9fee915a7a07a98e1a8e Mon Sep 17 00:00:00 2001 From: Michael Enger Date: Sun, 12 Sep 2021 20:14:01 +0100 Subject: [PATCH 20/28] Small cleanup (#501) * Add path segment wildcard test to testrunner * Fix compiler warning about class keyword * Fix (some) linter warnings --- Xcode/Sources/HttpServer.swift | 4 ++-- Xcode/Sources/HttpServerIO.swift | 2 +- Xcode/Sources/WebSockets.swift | 2 +- Xcode/SwifterSampleOSX/main.swift | 1 + Xcode/Tests/PingServer.swift | 2 +- Xcode/Tests/XCTestManifests.swift | 1 + 6 files changed, 7 insertions(+), 5 deletions(-) diff --git a/Xcode/Sources/HttpServer.swift b/Xcode/Sources/HttpServer.swift index 06f7f3f6..b8d56790 100644 --- a/Xcode/Sources/HttpServer.swift +++ b/Xcode/Sources/HttpServer.swift @@ -42,10 +42,10 @@ open class HttpServer: HttpServerIO { public var delete, patch, head, post, get, put: MethodRoute public subscript(path: String) -> ((HttpRequest) -> HttpResponse)? { + get { return nil } set { router.register(nil, path: path, handler: newValue) } - get { return nil } } public var routes: [String] { @@ -75,10 +75,10 @@ open class HttpServer: HttpServerIO { public let method: String public let router: HttpRouter public subscript(path: String) -> ((HttpRequest) -> HttpResponse)? { + get { return nil } set { router.register(method, path: path, handler: newValue) } - get { return nil } } } } diff --git a/Xcode/Sources/HttpServerIO.swift b/Xcode/Sources/HttpServerIO.swift index b20dc3fc..65d2df38 100644 --- a/Xcode/Sources/HttpServerIO.swift +++ b/Xcode/Sources/HttpServerIO.swift @@ -8,7 +8,7 @@ import Foundation import Dispatch -public protocol HttpServerIODelegate: class { +public protocol HttpServerIODelegate: AnyObject { func socketConnectionReceived(_ socket: Socket) } diff --git a/Xcode/Sources/WebSockets.swift b/Xcode/Sources/WebSockets.swift index a2d46e30..177813ad 100644 --- a/Xcode/Sources/WebSockets.swift +++ b/Xcode/Sources/WebSockets.swift @@ -277,7 +277,7 @@ public class WebSocketSession: Hashable, Equatable { } let mask = [try socket.read(), try socket.read(), try socket.read(), try socket.read()] - //Read payload all at once, then apply mask (calling `socket.read` byte-by-byte is super slow). + // Read payload all at once, then apply mask (calling `socket.read` byte-by-byte is super slow). frm.payload = try socket.read(length: Int(len)) for index in 0.. HttpServer { let server = HttpServer() - server.GET["/ping"] = { request in + server.GET["/ping"] = { _ in return HttpResponse.ok(.text("pong!")) } return server diff --git a/Xcode/Tests/XCTestManifests.swift b/Xcode/Tests/XCTestManifests.swift index 9f1f15c8..1e9e19e1 100644 --- a/Xcode/Tests/XCTestManifests.swift +++ b/Xcode/Tests/XCTestManifests.swift @@ -63,6 +63,7 @@ extension SwifterTestsHttpRouter { ("testHttpRouterHandlesOverlappingPathsInDynamicRoutes", testHttpRouterHandlesOverlappingPathsInDynamicRoutes), ("testHttpRouterHandlesOverlappingPathsInDynamicRoutesInTheMiddle", testHttpRouterHandlesOverlappingPathsInDynamicRoutesInTheMiddle), ("testHttpRouterMultiplePathSegmentWildcards", testHttpRouterMultiplePathSegmentWildcards), + ("testHttpRouterMultiplePathSegmentWildcardTail", testHttpRouterMultiplePathSegmentWildcardTail), ("testHttpRouterPercentEncodedPathSegments", testHttpRouterPercentEncodedPathSegments), ("testHttpRouterShouldHandleOverlappingRoutesInTrail", testHttpRouterShouldHandleOverlappingRoutesInTrail), ("testHttpRouterSimplePathSegments", testHttpRouterSimplePathSegments), From d76d0047351c6ee7ca0c67c6aaa2d31384e3045c Mon Sep 17 00:00:00 2001 From: Yuri Goncharov Date: Mon, 13 Sep 2021 13:28:10 +0300 Subject: [PATCH 21/28] updated CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0c1a3323..6f73fca3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,7 @@ All notable changes to this project will be documented in this file. Changes not # [Unreleased] ## Added +- Add custom headers into .ok HttpResponse. ([#500](https://github.com/httpswift/swifter/pull/500) by [@yuri-qualtie](https://github.com/yuri-qualtie) - Add support for using `**` as a catch-all at the end of a route. ([#479](https://github.com/httpswift/swifter/pull/479)) by [@michaelenger](https://github.com/michaelenger) - Set `Content-Type` to HttpBody and Text HttpResponse. ([#474](https://github.com/httpswift/swifter/pull/474)) by [@mtgto](https://github.com/mtgto) From fbc29f476a5cef822d326b2539641b3cb81c72e9 Mon Sep 17 00:00:00 2001 From: Jim Crate Date: Fri, 17 Sep 2021 14:31:38 -0400 Subject: [PATCH 22/28] Update CHANGELOG.md --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 332916bf..290702e6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,8 @@ All notable changes to this project will be documented in this file. Changes not - Set `Content-Type` to HttpBody and Text HttpResponse. ([#474](https://github.com/httpswift/swifter/pull/474)) by [@mtgto](https://github.com/mtgto) +- The `shareFile` function now sets `Content-Type` and `Content-Length` headers like `shareFilesFromDirectory. ([#493](https://github.com/httpswift/swifter/pull/493)) by [@jcrate](https://github.com/jcrate) + ## Fixed * Fix misspell `serialise`. ([#473](https://github.com/httpswift/swifter/pull/473)) by [@mtgto](https://github.com/mtgto) From 48a73318364e8c5c07f1c36308634696286ea6b7 Mon Sep 17 00:00:00 2001 From: Jim Crate Date: Fri, 17 Sep 2021 14:34:18 -0400 Subject: [PATCH 23/28] Update CHANGELOG.md fixing errant backtick. --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 290702e6..2eb830dc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,7 +22,7 @@ All notable changes to this project will be documented in this file. Changes not - Set `Content-Type` to HttpBody and Text HttpResponse. ([#474](https://github.com/httpswift/swifter/pull/474)) by [@mtgto](https://github.com/mtgto) -- The `shareFile` function now sets `Content-Type` and `Content-Length` headers like `shareFilesFromDirectory. ([#493](https://github.com/httpswift/swifter/pull/493)) by [@jcrate](https://github.com/jcrate) +- The `shareFile` function now sets `Content-Type` and `Content-Length` headers like `shareFilesFromDirectory`. ([#493](https://github.com/httpswift/swifter/pull/493)) by [@jcrate](https://github.com/jcrate) ## Fixed From f37324468ba07cb0b6f307017640bc6faacbb764 Mon Sep 17 00:00:00 2001 From: Michael Enger Date: Sun, 5 Sep 2021 13:40:41 +0100 Subject: [PATCH 24/28] Add tests for the Files functions --- Xcode/Swifter.xcodeproj/project.pbxproj | 8 ++ Xcode/Tests/FilesTests.swift | 100 ++++++++++++++++++++++++ 2 files changed, 108 insertions(+) create mode 100644 Xcode/Tests/FilesTests.swift diff --git a/Xcode/Swifter.xcodeproj/project.pbxproj b/Xcode/Swifter.xcodeproj/project.pbxproj index 0bdf6e94..ce264f99 100644 --- a/Xcode/Swifter.xcodeproj/project.pbxproj +++ b/Xcode/Swifter.xcodeproj/project.pbxproj @@ -48,6 +48,9 @@ 269B47981D3AAAE20042D137 /* Errno.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7C76B2A11D369C9D00D35BFB /* Errno.swift */; }; 269B47991D3AAAE20042D137 /* String+BASE64.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7C76B6F61D2C44F30030FC98 /* String+BASE64.swift */; }; 269B47A71D3AAC4F0042D137 /* SwiftertvOS.h in Headers */ = {isa = PBXBuildFile; fileRef = 269B47A51D3AAC4F0042D137 /* SwiftertvOS.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 39BFCFFA26E4F0A000A6D7BF /* FilesTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 39BFCFF926E4F0A000A6D7BF /* FilesTests.swift */; }; + 39BFCFFB26E4F0A000A6D7BF /* FilesTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 39BFCFF926E4F0A000A6D7BF /* FilesTests.swift */; }; + 39BFCFFC26E4F0A000A6D7BF /* FilesTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 39BFCFF926E4F0A000A6D7BF /* FilesTests.swift */; }; 6A0D4512204E9988000A0726 /* MimeTypesTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6A0D4511204E9988000A0726 /* MimeTypesTests.swift */; }; 6AE2FF722048013000302EC4 /* MimeTypes.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6AE2FF702048011A00302EC4 /* MimeTypes.swift */; }; 6AE2FF732048013000302EC4 /* MimeTypes.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6AE2FF702048011A00302EC4 /* MimeTypes.swift */; }; @@ -174,6 +177,7 @@ 269B47A11D3AAAE20042D137 /* Swifter.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Swifter.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 269B47A41D3AAC4F0042D137 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 269B47A51D3AAC4F0042D137 /* SwiftertvOS.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SwiftertvOS.h; sourceTree = ""; }; + 39BFCFF926E4F0A000A6D7BF /* FilesTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FilesTests.swift; sourceTree = ""; }; 540CA839228F275B00A3AF9B /* README.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = net.daringfireball.markdown; name = README.md; path = ../README.md; sourceTree = ""; }; 540CA83A228F275B00A3AF9B /* CHANGELOG.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = net.daringfireball.markdown; name = CHANGELOG.md; path = ../CHANGELOG.md; sourceTree = ""; }; 6A0D4511204E9988000A0726 /* MimeTypesTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MimeTypesTests.swift; sourceTree = ""; }; @@ -420,6 +424,7 @@ 7CCD876C1C660B250068099B /* Tests */ = { isa = PBXGroup; children = ( + 39BFCFF926E4F0A000A6D7BF /* FilesTests.swift */, 7B912F49220507D00062C360 /* XCTestManifests.swift */, 7CCB8C5F1D97B8CC008B9712 /* SwifterTestsHttpRouter.swift */, 7CCD876D1C660B250068099B /* SwifterTestsHttpParser.swift */, @@ -778,6 +783,7 @@ 043660D121FED35D00497989 /* SwifterTestsWebSocketSession.swift in Sources */, 043660D221FED36800497989 /* IOSafetyTests.swift in Sources */, 043660D021FED35B00497989 /* SwifterTestsStringExtensions.swift in Sources */, + 39BFCFFB26E4F0A000A6D7BF /* FilesTests.swift in Sources */, 043660CD21FED35200497989 /* SwifterTestsHttpRouter.swift in Sources */, 047F1F02226AB9AD00909B95 /* XCTestManifests.swift in Sources */, 043660CE21FED35500497989 /* SwifterTestsHttpParser.swift in Sources */, @@ -798,6 +804,7 @@ 043660E521FED51100497989 /* SwifterTestsHttpRouter.swift in Sources */, 7B55EC97226E0E4F00042D23 /* ServerThreadingTests.swift in Sources */, 043660E621FED51400497989 /* SwifterTestsHttpParser.swift in Sources */, + 39BFCFFC26E4F0A000A6D7BF /* FilesTests.swift in Sources */, 043660EB21FED52000497989 /* MimeTypesTests.swift in Sources */, 0C1F3CAF2265FC470076B6F5 /* SwifterTestsHttpResponseBody.swift in Sources */, ); @@ -909,6 +916,7 @@ 6A0D4512204E9988000A0726 /* MimeTypesTests.swift in Sources */, 6AE2FF752048013300302EC4 /* MimeTypes.swift in Sources */, 0858E7F81D68BC2600491CD1 /* PingServer.swift in Sources */, + 39BFCFFA26E4F0A000A6D7BF /* FilesTests.swift in Sources */, 7C4785E91C71D15600A9FE73 /* SwifterTestsWebSocketSession.swift in Sources */, 043660D421FED36900497989 /* IOSafetyTests.swift in Sources */, 7CCD87721C660B250068099B /* SwifterTestsStringExtensions.swift in Sources */, diff --git a/Xcode/Tests/FilesTests.swift b/Xcode/Tests/FilesTests.swift new file mode 100644 index 00000000..1f884844 --- /dev/null +++ b/Xcode/Tests/FilesTests.swift @@ -0,0 +1,100 @@ +// +// FilesTests.swift +// Swifter +// +// Created by Michael Enger on 02/09/2021. +// Copyright © 2021 Damian Kołakowski. All rights reserved. +// + +import XCTest +#if os(Linux) +import FoundationNetworking +#endif +@testable import Swifter + +class FilesTests: XCTestCase { + let temporaryDirectoryURL = URL(fileURLWithPath: NSTemporaryDirectory(), isDirectory: true) + let temporaryFileName = UUID().uuidString + ".png" + + override func setUp() { + super.setUp() + + let temporaryFileURL = temporaryDirectoryURL.appendingPathComponent(temporaryFileName) + let data = "This is a file" + do { + try data.write(to: temporaryFileURL, atomically: true, encoding: String.Encoding.utf8) + } catch { + XCTFail("Failed to create temporary file") + } + } + + override func tearDown() { + let temporaryFileURL = temporaryDirectoryURL.appendingPathComponent(temporaryFileName) + do { + try FileManager.default.removeItem(at: temporaryFileURL) + } catch { + // no worries + } + + super.tearDown() + } + + func testShareFile() { + let request = HttpRequest() + let closure = shareFile(temporaryDirectoryURL.appendingPathComponent(temporaryFileName).path) + let result = closure(request) + let headers = result.headers() + + XCTAssert(result.statusCode == 200) + XCTAssert(headers["Content-Type"] == "image/png") + XCTAssert(headers["Content-Length"] == "14") + } + + func testShareFileNotFound() { + let request = HttpRequest() + let closure = shareFile(temporaryDirectoryURL.appendingPathComponent("does_not_exist").path) + let result = closure(request) + + XCTAssert(result == .notFound) + } + + func testShareFilesFromDirectory() { + let request = HttpRequest() + request.params = ["path": temporaryFileName] + let closure = shareFilesFromDirectory(temporaryDirectoryURL.path) + let result = closure(request) + let headers = result.headers() + + XCTAssert(result.statusCode == 200) + XCTAssert(headers["Content-Type"] == "image/png") + XCTAssert(headers["Content-Length"] == "14") + } + + func testShareFilesFromDirectoryFileNotFound() { + let request = HttpRequest() + request.params = ["path": "does_not_exist.wav"] + + let closure = shareFilesFromDirectory(temporaryDirectoryURL.path) + let result = closure(request) + + XCTAssert(result == .notFound) + } + + func testDirectoryBrowser() { + let request = HttpRequest() + request.params = ["path": ""] + let closure = directoryBrowser(temporaryDirectoryURL.path) + let result = closure(request) + + XCTAssert(result.statusCode == 200) + } + + func testDirectoryBrowserNotFound() { + let request = HttpRequest() + request.params = ["path": "does/not/exist"] + let closure = directoryBrowser(temporaryDirectoryURL.path) + let result = closure(request) + + XCTAssert(result == .notFound) + } +} From 9e31b68aab2a206bb8f20448e0a65e441fdd1d2c Mon Sep 17 00:00:00 2001 From: Michael Enger Date: Sun, 5 Sep 2021 14:25:42 +0100 Subject: [PATCH 25/28] Update test manifest file --- Xcode/Tests/XCTestManifests.swift | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/Xcode/Tests/XCTestManifests.swift b/Xcode/Tests/XCTestManifests.swift index 1e9e19e1..29f22b08 100644 --- a/Xcode/Tests/XCTestManifests.swift +++ b/Xcode/Tests/XCTestManifests.swift @@ -1,6 +1,20 @@ #if !canImport(ObjectiveC) import XCTest +extension FilesTests { + // DO NOT MODIFY: This is autogenerated, use: + // `swift test --generate-linuxmain` + // to regenerate. + static let __allTests__FilesTests = [ + ("testDirectoryBrowser", testDirectoryBrowser), + ("testDirectoryBrowserNotFound", testDirectoryBrowserNotFound), + ("testShareFile", testShareFile), + ("testShareFileNotFound", testShareFileNotFound), + ("testShareFilesFromDirectory", testShareFilesFromDirectory), + ("testShareFilesFromDirectoryFileNotFound", testShareFilesFromDirectoryFileNotFound), + ] +} + extension IOSafetyTests { // DO NOT MODIFY: This is autogenerated, use: // `swift test --generate-linuxmain` @@ -98,6 +112,7 @@ extension SwifterTestsWebSocketSession { public func __allTests() -> [XCTestCaseEntry] { return [ + testCase(FilesTests.__allTests__FilesTests), testCase(MimeTypeTests.__allTests__MimeTypeTests), testCase(ServerThreadingTests.__allTests__ServerThreadingTests), testCase(SwifterTestsHttpParser.__allTests__SwifterTestsHttpParser), From c11dbd15698ffdd95b74fc1019db67ab2901dcdd Mon Sep 17 00:00:00 2001 From: mtgto Date: Wed, 29 Sep 2021 06:23:00 +0900 Subject: [PATCH 26/28] Adds response body to any http response (#476) Co-authored-by: Michael Enger --- CHANGELOG.md | 3 ++- Xcode/Sources/Files.swift | 14 +++++++------- Xcode/Sources/HttpResponse.swift | 6 ++---- Xcode/Sources/HttpServerIO.swift | 2 +- 4 files changed, 12 insertions(+), 13 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6055c548..18a8d5d9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,11 +19,12 @@ All notable changes to this project will be documented in this file. Changes not # [Unreleased] ## Added + - Add custom headers into .ok HttpResponse. ([#500](https://github.com/httpswift/swifter/pull/500) by [@yuri-qualtie](https://github.com/yuri-qualtie) - Add support for using `**` as a catch-all at the end of a route. ([#479](https://github.com/httpswift/swifter/pull/479)) by [@michaelenger](https://github.com/michaelenger) - Set `Content-Type` to HttpBody and Text HttpResponse. ([#474](https://github.com/httpswift/swifter/pull/474)) by [@mtgto](https://github.com/mtgto) - - The `shareFile` function now sets `Content-Type` and `Content-Length` headers like `shareFilesFromDirectory`. ([#493](https://github.com/httpswift/swifter/pull/493)) by [@jcrate](https://github.com/jcrate) +- Adds response body to any http response. ([#476](https://github.com/httpswift/swifter/pull/476) by [@mtgto](https://github.com/mtgto) ## Fixed diff --git a/Xcode/Sources/Files.swift b/Xcode/Sources/Files.swift index 1905e6bb..a45e2c5b 100644 --- a/Xcode/Sources/Files.swift +++ b/Xcode/Sources/Files.swift @@ -22,14 +22,14 @@ public func shareFile(_ path: String) -> ((HttpRequest) -> HttpResponse) { file.close() }) } - return .notFound + return .notFound() } } public func shareFilesFromDirectory(_ directoryPath: String, defaults: [String] = ["index.html", "default.html"]) -> ((HttpRequest) -> HttpResponse) { return { request in guard let fileRelativePath = request.params.first else { - return .notFound + return .notFound() } if fileRelativePath.value.isEmpty { for path in defaults { @@ -57,19 +57,19 @@ public func shareFilesFromDirectory(_ directoryPath: String, defaults: [String] file.close() }) } - return .notFound + return .notFound() } } public func directoryBrowser(_ dir: String) -> ((HttpRequest) -> HttpResponse) { return { request in guard let (_, value) = request.params.first else { - return HttpResponse.notFound + return .notFound() } let filePath = dir + String.pathSeparator + value do { guard try filePath.exists() else { - return .notFound + return .notFound() } if try filePath.directory() { var files = try filePath.files() @@ -92,7 +92,7 @@ public func directoryBrowser(_ dir: String) -> ((HttpRequest) -> HttpResponse) { }(request) } else { guard let file = try? filePath.openForReading() else { - return .notFound + return .notFound() } return .raw(200, "OK", [:], { writer in try? writer.write(file) @@ -100,7 +100,7 @@ public func directoryBrowser(_ dir: String) -> ((HttpRequest) -> HttpResponse) { }) } } catch { - return HttpResponse.internalServerError + return HttpResponse.internalServerError(.text("Internal Server Error")) } } } diff --git a/Xcode/Sources/HttpResponse.swift b/Xcode/Sources/HttpResponse.swift index 9d50ed65..cef8aa41 100644 --- a/Xcode/Sources/HttpResponse.swift +++ b/Xcode/Sources/HttpResponse.swift @@ -83,9 +83,7 @@ public enum HttpResponse { case ok(HttpResponseBody, [String: String] = [:]), created, accepted case movedPermanently(String) case movedTemporarily(String) - case badRequest(HttpResponseBody?), unauthorized, forbidden, notFound, notAcceptable - case tooManyRequests - case internalServerError + case badRequest(HttpResponseBody?), unauthorized(HttpResponseBody?), forbidden(HttpResponseBody?), notFound(HttpResponseBody? = nil), notAcceptable(HttpResponseBody?), tooManyRequests(HttpResponseBody?), internalServerError(HttpResponseBody?) case raw(Int, String, [String: String]?, ((HttpResponseBodyWriter) throws -> Void)? ) public var statusCode: Int { @@ -162,7 +160,7 @@ public enum HttpResponse { func content() -> (length: Int, write: ((HttpResponseBodyWriter) throws -> Void)?) { switch self { case .ok(let body, _) : return body.content() - case .badRequest(let body) : return body?.content() ?? (-1, nil) + case .badRequest(let body), .unauthorized(let body), .forbidden(let body), .notFound(let body), .tooManyRequests(let body), .internalServerError(let body) : return body?.content() ?? (-1, nil) case .raw(_, _, _, let writer) : return (-1, writer) default : return (-1, nil) } diff --git a/Xcode/Sources/HttpServerIO.swift b/Xcode/Sources/HttpServerIO.swift index 65d2df38..65c6e95a 100644 --- a/Xcode/Sources/HttpServerIO.swift +++ b/Xcode/Sources/HttpServerIO.swift @@ -112,7 +112,7 @@ open class HttpServerIO { } open func dispatch(_ request: HttpRequest) -> ([String: String], (HttpRequest) -> HttpResponse) { - return ([:], { _ in HttpResponse.notFound }) + return ([:], { _ in HttpResponse.notFound(nil) }) } private func handleConnection(_ socket: Socket) { From eea4bb1e652c2e7aaf09bab39065b1c81a36d2e1 Mon Sep 17 00:00:00 2001 From: p-krasnobrovkin-tcs <74640150+p-krasnobrovkin-tcs@users.noreply.github.com> Date: Wed, 29 Sep 2021 00:34:44 +0300 Subject: [PATCH 27/28] Set Swift version to 5.0 in Podspec (#475) * Make swift version 5.0 * Add Changelog entry Co-authored-by: Michael Enger --- CHANGELOG.md | 6 ++++-- Swifter.podspec | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 18a8d5d9..a4eb5a6f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ All notable changes to this project will be documented in this file. Changes not # [Unreleased] + ## Added - Add custom headers into .ok HttpResponse. ([#500](https://github.com/httpswift/swifter/pull/500) by [@yuri-qualtie](https://github.com/yuri-qualtie) @@ -28,8 +29,9 @@ All notable changes to this project will be documented in this file. Changes not ## Fixed -* Fix misspell `serialise`. ([#473](https://github.com/httpswift/swifter/pull/473)) by [@mtgto](https://github.com/mtgto) -* Fix an issue causing Danger was not working properly. ([#486](https://github.com/httpswift/swifter/pull/486)) by [@Vkt0r](https://github.com/Vkt0r) +- Fix misspell `serialise`. ([#473](https://github.com/httpswift/swifter/pull/473)) by [@mtgto](https://github.com/mtgto) +- Fix an issue causing Danger was not working properly. ([#486](https://github.com/httpswift/swifter/pull/486)) by [@Vkt0r](https://github.com/Vkt0r) +- Set Swift version to 5.0 in podspec. ([#475](https://github.com/httpswift/swifter/pull/475)) by [@p-krasnobrovkin-tcs](https://github.com/p-krasnobrovkin-tcs) ## Changed diff --git a/Swifter.podspec b/Swifter.podspec index 79766903..73b4a501 100644 --- a/Swifter.podspec +++ b/Swifter.podspec @@ -11,6 +11,6 @@ Pod::Spec.new do |s| s.tvos.deployment_target = "9.0" s.source = { :git => "https://github.com/httpswift/swifter.git", :tag => "1.5.0" } s.source_files = 'Xcode/Sources/*.{swift}' - s.swift_version = '4.2' + s.swift_version = '5.0' -end \ No newline at end of file +end From ef326c421eee485f82c664f62cda95635dc71020 Mon Sep 17 00:00:00 2001 From: Sergey Erokhin Date: Tue, 25 May 2021 17:05:31 +0300 Subject: [PATCH 28/28] Improved performance of reading --- CHANGELOG.md | 1 + Xcode/Sources/Socket.swift | 10 +++------- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a4eb5a6f..3779fb6c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -32,6 +32,7 @@ All notable changes to this project will be documented in this file. Changes not - Fix misspell `serialise`. ([#473](https://github.com/httpswift/swifter/pull/473)) by [@mtgto](https://github.com/mtgto) - Fix an issue causing Danger was not working properly. ([#486](https://github.com/httpswift/swifter/pull/486)) by [@Vkt0r](https://github.com/Vkt0r) - Set Swift version to 5.0 in podspec. ([#475](https://github.com/httpswift/swifter/pull/475)) by [@p-krasnobrovkin-tcs](https://github.com/p-krasnobrovkin-tcs) +- Improved performance of data reading. ([#487](https://github.com/httpswift/swifter/pull/487)) by [@till0xff](https://github.com/till0xff) ## Changed diff --git a/Xcode/Sources/Socket.swift b/Xcode/Sources/Socket.swift index 590360c7..1a9887e9 100644 --- a/Xcode/Sources/Socket.swift +++ b/Xcode/Sources/Socket.swift @@ -149,13 +149,9 @@ open class Socket: Hashable, Equatable { /// - Returns: A buffer containing the bytes read /// - Throws: SocketError.recvFailed if unable to read bytes from the socket open func read(length: Int) throws -> [UInt8] { - var buffer = UnsafeMutableBufferPointer.allocate(capacity: length) - - let bytesRead = try read(into: &buffer, length: length) - - let rv = [UInt8](buffer[0..