Skip to content

[SR-8759] httpBody is not sent by URLSessionDataTask to the server that URLSession has received cookie #3636

@norio-nomura

Description

@norio-nomura
Previous ID SR-8759
Radar None
Original Reporter @norio-nomura
Type Bug
Status Resolved
Resolution Done

Attachment: Download

Environment

swift-4.2-DEVELOPMENT-SNAPSHOT-2018-09-07-a or later on Linux

Additional Detail from JIRA
Votes 0
Component/s Foundation
Labels Bug
Assignee None
Priority Medium

md5: aa18d826eb92d2c55d1554ebd6caceb4

Issue Description:

Reproducing steps

  1. docker run -it --rm norionomura/swift:4220180907a

  2. curl -s https://gist.githubusercontent.com/norio-nomura/73c3a12db6a9d615e239954259ff89cf/raw/00b4351496c153e13af0a2674bb8fe75e661a70f/httpBodyIsNotSentToTheDomainThatReceivedCookie.swift|swift -

log:

$ docker run -it --rm norionomura/swift:4220180907a
root@a6b6631911aa:/# curl -s https://gist.githubusercontent.com/norio-nomura/73c3a12db6a9d615e239954259ff89cf/raw/00b4351496c153e13af0a2674bb8fe75e661a70f/httpBodyIsNotSentToTheDomainThatReceivedCookie.swift|swift -
request.httpBody: Optional(15 bytes)
postTask.originalRequest.httpBody: nil
-- response body begin
{
  "args": {}, 
  "data": "", 
  "files": {}, 
  "form": {}, 
  "headers": {
    "Accept": "*/*", 
    "Accept-Encoding": "deflate, gzip", 
    "Accept-Language": "en", 
    "Connection": "close", 
    "Content-Length": "0", 
    "Content-Type": "application/json", 
    "Cookie": "freeform=test", 
    "Host": "httpbin.org", 
    "User-Agent": "swift (unknown version) curl/7.47.0"
  }, 
  "json": null, 
  "origin": "180.196.246.165", 
  "url": "http://httpbin.org/post"
}

-- response body end

postTask.originalRequest.httpBody: nil indicates httpBody is lost.
Response body indicates {{httpBody is not received on http://httpbin.org/post.

Until swift-4.2-DEVELOPMENT-SNAPSHOT-2018-08-25-a, it works as expected.

$ docker run -it --rm norionomura/swift:4220180825a
root@452e49dbf55d:/# curl -s https://gist.githubusercontent.com/norio-nomura/73c3a12db6a9d615e239954259ff89cf/raw/00b4351496c153e13af0a2674bb8fe75e661a70f/httpBodyIsNotSentToTheDomainThatReceivedCookie.swift|swift -
request.httpBody: Optional(15 bytes)
postTask.originalRequest.httpBody: Optional(15 bytes)
-- response body begin
{
  "args": {}, 
  "data": "{\"key\":\"value\"}", 
  "files": {}, 
  "form": {}, 
  "headers": {
    "Accept": "*/*", 
    "Accept-Encoding": "deflate, gzip", 
    "Accept-Language": "en", 
    "Connection": "close", 
    "Content-Length": "15", 
    "Content-Type": "application/json", 
    "Host": "httpbin.org", 
    "User-Agent": "swift (unknown version) curl/7.47.0"
  }, 
  "json": {
    "key": "value"
  }, 
  "origin": "180.196.246.165", 
  "url": "http://httpbin.org/post"
}

-- response body end

postTask.originalRequest.httpBody: Optional(15 bytes) indicates that httpBody is passed to URLSessionDataTask.
It succeeded to post httpBody to http://httpbin.org/post.

swift-4.2-branch branch is affected by this issue.
master branch is not affected by this issue.

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