Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

POST call handles HTTP 302 redirection wrong #368

Closed
dgrechka opened this issue May 19, 2016 · 1 comment
Closed

POST call handles HTTP 302 redirection wrong #368

dgrechka opened this issue May 19, 2016 · 1 comment

Comments

@dgrechka
Copy link

dgrechka commented May 19, 2016

When I do post request

POST(url,path="/api/compute",accept("text/plain"),content_type("application/json"),body=jsonRequest)

and the server reply with HTTP 302 redirect, the httr (or curl?) follows the new location but issues GET request to this new location instead of origin all POST.

The traffic capture:

Request 1:

POST //api/compute HTTP/1.1
Host: fetchclimate.org
User-Agent: libcurl/7.47.1 r-curl/0.9.7 httr/1.1.0
Accept-Encoding: gzip, deflate
Accept: text/plain
Content-Type: application/json
Content-Length: 565

{
  "EnvironmentVariableName": "airt",
  "ParticularDataSources": "",
  "Domain": {
    "Lats": [55.5],
    "Lats2": null,
    "Lons": [37.3],
    "Lons2": null,
    "TimeRegion": {
      "Years": [2008, 2009],
      "Days": [183, 214],
      "Hours": [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25],
      "IsIntervalsGridYears": true,
      "IsIntervalsGridDays": true,
      "IsIntervalsGridHours": true
    },
    "Mask": null,
    "SpatialRegionType": "Points"
  },
  "ReproducibilityTimestamp": 253404979199999
}

Response 1:

HTTP/1.1 302 Redirect
Content-Type: text/html; charset=UTF-8
Location: http://fetchclimate2.cloudapp.net/api/compute
Server: Microsoft-IIS/8.5
X-Powered-By: ASP.NET
Strict-Transport-Security: max-age=31536000
Date: Thu, 19 May 2016 21:09:18 GMT
Content-Length: 168

<head><title>Document Moved</title></head>
<body><h1>Object Moved</h1>This document may be found <a HREF="http://fetchclimate2.cloudapp.net/api/compute">here</a></body>

Request 2:

POST /api/compute HTTP/1.1
Host: fetchclimate2.cloudapp.net
User-Agent: libcurl/7.47.1 r-curl/0.9.7 httr/1.1.0
Accept-Encoding: gzip, deflate
Accept: text/plain
Content-Type: application/json

Request 2 is expected to contain the same body as request 1, but it contains nither Content-Length header no request body

HTTP/1.1 411 Length Required
Content-Type: text/html; charset=us-ascii
Server: Microsoft-HTTPAPI/2.0
Date: Thu, 19 May 2016 21:09:18 GMT
Connection: close
Content-Length: 344

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN""http://www.w3.org/TR/html4/strict.dtd">
<HTML><HEAD><TITLE>Length Required</TITLE>
<META HTTP-EQUIV="Content-Type" Content="text/html; charset=us-ascii"></HEAD>
<BODY><h2>Length Required</h2>
<hr><p>HTTP Error 411. The request must be chunked or have a content length.</p>
</BODY></HTML>
@hadley
Copy link
Member

hadley commented May 20, 2016

Duplicate of #356

@hadley hadley closed this as completed May 20, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants