-
Notifications
You must be signed in to change notification settings - Fork 8.1k
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
Redirect from POST ends in 404, even if the endpoint exists #444
Comments
Obs: Moving status to 301 solved the issue. |
Instead of a 301, I think a 302 |
Yeah, I agree, both (301, 302) work. |
It is intended behaviour. To quote httpstatus.es, a 307 tells the client to "connect again to different URI as provided". Since the original request was a POST request, the client will try to connect again using a POST request. |
Same problem, but both(301, 302) does not work~ func (pins *PinsController) PostFile(c *gin.Context) {
fileSize := c.Request.ContentLength
// 1. Look up for the most freespace node
node, err := services.GetFreeNode(fileSize)
HandleError(err)
// 2. Redirect to that node
redirectUrl := fmt.Sprintf("http://%s/", node.Address)
fmt.Println(redirectUrl)
c.Redirect(http.StatusTemporaryRedirect, redirectUrl)
} And I got 404 using ~ http -f POST :8080/api/v1/ name='file' file@~/Documents/Learning/java --follow
HTTP/1.1 404 Not Found
Content-Length: 18
Content-Type: text/plain
Date: Mon, 15 Apr 2019 14:07:59 GMT
Proxy-Connection: keep-alive
404 page not found I try every 30X status code, found 308 works fine. ~ http -f POST :8080/api/v1/ name='file' file@~/Documents/Learning/kotlin-docs.pdf --all
http: error: ConnectionError: ('Connection aborted.', BrokenPipeError(32, 'Broken pipe')) while doing POST request to URL: http://localhost:8080/api/v1/ Anybody can help me~~~ 🤒 |
@zikunfan Maybe you should change |
Refer to issue gin-gonic#444
* Add a redirect sample for POST method Refer to issue #444 * put an empty line before 1396 Co-authored-by: Bo-Yi Wu <appleboy.tw@gmail.com>
I meet the same problem |
tscolari this problem is solved ? I am meeting this problem |
Im sorry but I haven’t used this library in a while, so I can’t comment. |
I've made a sample code to explain what's happening:
When it tries to redirect from a POST to
/login/do
to/welcome
the result is 404 (404 page not found
).But if I try to go directly to
/welcome
everything works fine.Am I doing something wrong?
The text was updated successfully, but these errors were encountered: