Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix default content type test failure
  • Loading branch information
MaxDesiatov committed Aug 2, 2023
commit 58a5d0ee746095232f7e5a2c897f76f0ea82dfef
2 changes: 1 addition & 1 deletion Sources/SwiftDocC/Servers/FileServer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public class FileServer {
if let data = data {
response = .init(status: .ok, headerFields: [.contentType: mimeType, .contentLength: "\(data.count)"])
} else {
response = .init(status: .ok, headerFields: [.contentType: mimeType])
response = .init(status: .ok, headerFields: [.contentType: "application/octet-stream"])
}

return (response, data)
Expand Down
7 changes: 0 additions & 7 deletions Tests/SwiftDocCTests/Servers/FileServerTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -181,14 +181,7 @@ class FileServerTests: XCTestCase {

let failingRequest = HTTPRequest(path: "/not/found.jpg")
(response, data) = fileServer.response(to: failingRequest)
XCTAssertNil(data)
// Initializing a URLResponse with `nil` as MIME type in Linux returns nil
#if os(Linux) || os(Android) || os(Windows)
XCTAssertNil(response.mimeType)
#else
// Doing the same in macOS or iOS returns the default MIME type
XCTAssertEqual(response.mimeType, "application/octet-stream")
#endif
}

func testRedirectToHome() {
Expand Down