Skip to content

Commit

Permalink
Fix for handling of post with empty post body
Browse files Browse the repository at this point in the history
  • Loading branch information
Mike Kistler committed Oct 31, 2018
1 parent 1430998 commit d00aea1
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion Foundation/URLSession/http/HTTPURLProtocol.swift
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,8 @@ internal class _HTTPURLProtocol: _NativeProtocol {
}
let customHeaders: [String]
let headersForRequest = curlHeaders(for: httpHeaders)
if ((request.httpMethod == "POST") && (request.value(forHTTPHeaderField: "Content-Type") == nil)) {
if ((request.httpMethod == "POST") && (request.httpBody?.count ?? 0 > 0)
&& (request.value(forHTTPHeaderField: "Content-Type") == nil)) {
customHeaders = headersForRequest + ["Content-Type:application/x-www-form-urlencoded"]
} else {
customHeaders = headersForRequest
Expand Down

0 comments on commit d00aea1

Please sign in to comment.