func checkContentDispositionHeader()

in Sources/PackageRegistryCompatibilityTestSuite/APITests/APITest.swift [68:83]


    func checkContentDispositionHeader(_ headers: HTTPHeaders, expectedFilename: String, isRequired: Bool, for testCase: inout TestCase) {
        testCase.mark("\"Content-Disposition\" response header")
        let contentDispositionHeader = headers["Content-Disposition"].first
        if contentDispositionHeader == nil {
            if isRequired {
                testCase.error("Missing \"Content-Disposition\" header")
            } else {
                testCase.warning("\"Content-Disposition\" header should be set")
            }
        } else {
            let expected = "attachment; filename=\"\(expectedFilename)\""
            if let contentDispositionHeader = contentDispositionHeader, contentDispositionHeader.lowercased() != expected.lowercased() {
                testCase.error("Expected \"\(expected)\" for \"Content-Disposition\" header but got \"\(contentDispositionHeader)\"")
            }
        }
    }