question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Request method changed on redirect

See original GitHub issue

Hi,

I’m using axios v0.17.0 with HEAD method like this:

axios.head('http://example.com');

(let’s suppose http://example.com is set to redirect 301 to http://www.example.com)

For some reason Request method will change on the first redirect to GET instead of keeping HEAD all the way down. This will read in logs like this:

example.com:80 10.0.0.1 - - "HEAD / HTTP/1.1" 301 237 "-" "axios/0.17.0"
example.com:80 10.0.0.1 - - "GET / HTTP/1.1" 200 246 "-" "axios/0.17.0"

instead of this:

example.com:80 10.0.0.1 - - "HEAD / HTTP/1.1" 301 237 "-" "axios/0.17.0"
example.com:80 10.0.0.1 - - "HEAD / HTTP/1.1" 200 246 "-" "axios/0.17.0"

When I do the test in Firefox it keeps original request method (HEAD) all the way down.

Any idea why is this?

Thanks, Milos

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
alcalbgcommented, Nov 4, 2017

It turns out that olalonde/follow-redirects package is following RFC specifications which says that Request method is case-sensitive as pointed out by @RubenVerborg here but axios is passing lowecase verb head causing the wrong redirect behavior.

0reactions
axe312gercommented, Aug 23, 2018

If your PR has a test case for this I am happy to review it 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Redirections in HTTP - MDN Web Docs - Mozilla
URL redirection, also known as URL forwarding, is a technique to give more than one URL address to a page, a form, or...
Read more >
Retain http method on redirect - Stack Overflow
I.e. /user should be redirected too /en/user . This works fine for most request unless the method is POST and there is no...
Read more >
Request method POST gets changed to GET after redirect
The command HTTP::redirect sends an HTTP 302 response code which changes the HTTP method in the next request to GET. Recommended Actions.
Read more >
Redirect 302 changes method from POST to GET #138 - GitHub
I'm having some problems when following https redirects with wreck. I have this code: server.ext('onRequest', function (request, ...
Read more >
HTTP method changed in IS after receiving HTTP 301 Redirect
Hi, We are consuming a REST API from Salesforce and made a HTTP PATCH call from the Integration Server to Salesforce.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found