Skip to content

[SR-2617] corelibs-foundation URLSession.dataTask() ignores httpBody #4447

Closed
@swift-ci

Description

@swift-ci
Previous ID SR-2617
Radar None
Original Reporter klassobanieras (JIRA User)
Type Bug
Status Resolved
Resolution Done
Environment

swift-3.0-GM-CANDIDATE
Ubuntu 14.04.5 LTS (GNU/Linux 4.4.0-34-generic x86_64)

Additional Detail from JIRA
Votes 1
Component/s Foundation
Labels Bug
Assignee seabaylea (JIRA)
Priority Medium

md5: 14dfeae41c1d30c4881bf7cdc79537be

Issue Description:

Sending a URLRequest with httpBody set, using URLSession.dataTask(), ignores the httpBody on Linux + corelibs-foundation. A body is only sent if passed directly to uploadTask().

The following illustrates the difference when run on Mac vs Linux:

import Foundation
import Dispatch

var req = URLRequest(url: URL(string: "http://httpbin.org/post")!)
req.httpMethod = "POST"
req.httpBody = "Hello! You should see me in the 'form' parameter of the result.".data(using: .utf8)

let sesh = URLSession(configuration: URLSessionConfiguration.default)

let dataTask = sesh.dataTask(with: req) { data, _, _ in
        print(String(data: data!, encoding: .utf8)!)
        exit(0)
}
dataTask.resume()
dispatchMain()

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions