Skip to content

Commit 74532d9

Browse files
author
Christian Steffens
committed
Adds new case htmlBody(String) to HttpResponse
1 parent 86646b5 commit 74532d9

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ All notable changes to this project will be documented in this file. Changes not
2222
- A new `CHANGELOG.md` to keep track of changes in the project. ([#385](https://github.com/httpswift/swifter/pull/385)) by [@Vkt0r](https://github.com/Vkt0r)
2323
- Added [Danger](https://danger.systems/ruby/) and Swiftlint to the project. ([#398](https://github.com/httpswift/swifter/pull/398)) by [@Vkt0r](https://github.com/Vkt0r)
2424
- Added the following to `Scopes`: `manifest`, `ontouchstart`, `dataText`. ([#410](https://github.com/httpswift/swifter/pull/410)) by [@apocolipse](https://github.com/apocolipse)
25+
- Added `htmlBody(String)` to `HttpResonse` as a compability case for the changed `html(String)` case.
2526

2627
## Fixed
2728
- An issue causing a crash regarding a thread race condition. ([#399](https://github.com/httpswift/swifter/pull/399)) by [@Vkt0r](https://github.com/Vkt0r)
@@ -37,7 +38,8 @@ All notable changes to this project will be documented in this file. Changes not
3738
- Refactor: Use Foundation API for Base64 encoding. ([#403](https://github.com/httpswift/swifter/pull/403)) by [@mazyod](https://github.com/mazyod)
3839
- Refactor: Use `URLComponents` for `HttpRequest` path and query parameters parsing [#404](https://github.com/httpswift/swifter/pull/404)) by [@mazyod](https://github.com/mazyod)
3940
- `HttpResponse` functions `statusCode()` and `reasonPhrase` changed to computed variables instead of functions, and made public (No impact on existing usage as it was previously internal). ([#410](https://github.com/httpswift/swifter/pull/410)) by [@apocolipse](https://github.com/apocolipse)
40-
41+
- `HttpResponse`: `html` requires now a complete html-string, not only the body-part.
42+
- Include the `CHANGELOG.md` and `README.md` in the Xcode-Project for easy access / changes.
4143

4244
## Removed
4345
- Dropped macOS 10.9 support [#404](https://github.com/httpswift/swifter/pull/404)), [#408](https://github.com/httpswift/swifter/pull/408)) by [@mazyod](https://github.com/mazyod), [@Vkt0r](https://github.com/Vkt0r)

XCode/Sources/HttpResponse.swift

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ public enum HttpResponseBody {
2424

2525
case json(AnyObject)
2626
case html(String)
27+
case htmlBody(String)
2728
case text(String)
2829
case data(Data)
2930
case custom(Any, (Any) throws -> String)
@@ -51,7 +52,12 @@ public enum HttpResponseBody {
5152
return (data.count, {
5253
try $0.write(data)
5354
})
54-
case .html(let body):
55+
case .html(let html):
56+
let data = [UInt8](html.utf8)
57+
return (data.count, {
58+
try $0.write(data)
59+
})
60+
case .htmlBody(let body):
5561
let serialised = "<html><meta charset=\"UTF-8\"><body>\(body)</body></html>"
5662
let data = [UInt8](serialised.utf8)
5763
return (data.count, {

0 commit comments

Comments
 (0)