Skip to content
This repository has been archived by the owner on Dec 10, 2024. It is now read-only.

Allow non-filename HTTPFile.text #90

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
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
11 changes: 8 additions & 3 deletions Sources/Just/Just.swift
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ let statusCodeDescriptions = [
public enum HTTPFile {
case url(URL, String?) // URL to a file, mimetype
case data(String, Foundation.Data, String?) // filename, data, mimetype
case text(String, String, String?) // filename, text, mimetype
case text(String?, String, String?) // filename, text, mimetype
}

// Supported request types
Expand Down Expand Up @@ -850,8 +850,13 @@ public final class HTTP: NSObject, URLSessionDelegate, JustAdaptor {
partContent = data
partMimetype = mimetype
}
if let content = partContent, let filename = partFilename {
let dispose = "Content-Disposition: form-data; name=\"\(k)\"; filename=\"\(filename)\"\r\n"
if let content = partContent {
let dispose: String
if let filename = partFilename {
dispose = "Content-Disposition: form-data; name=\"\(k)\"; filename=\"\(filename)\"\r\n"
} else {
dispose = "Content-Disposition: form-data; name=\"\(k)\"\r\n"
}
body.append(dispose.data(using: defaults.encoding)!)
if let type = partMimetype {
body.append(
Expand Down