Skip to content

Handle redirects for Yun shield sketch upload #99

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

Conversation

sandeepmistry
Copy link
Contributor

@sandeepmistry sandeepmistry commented May 13, 2016

When POST'ing a sketch for upload to /data/upload_sketch_silent, it returns a 302 Found response with a Location of /cgi-bin/luci/;stok=<stok>/data/upload_sketch_silent. The Go HTTP client will attempt to do a GET request for this redirect (instead of POST) and get a 401 response because there is no Authentication header in the request.

This change will make spProgramNetwork POST a new request to the redirected URL when this condition is encountered.

It would be nice to change the behaviour of the Yun Shield REST service to not redirect, because the sketch data is sent twice over the network. If this is not possible, then we can use this patch instead.

cc/ @facchinm @matteosuppo

Signed-off-by: Sandeep Mistry <s.mistry@arduino.cc>
Signed-off-by: Sandeep Mistry <s.mistry@arduino.cc>
// Don't forget to close the multipart writer.
// If you don't close it, your request will be missing the terminating boundary.
w.Close()
var cookies []*http.Cookie
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does it need cookies?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you don't set a cookie from the 302 response, you keep on redirecting.

We need to discuss this behaviour with @facchinm.

@facchinm
Copy link
Member

The only problem I see here is that the Yun101 (or a Yun updated to fw 1.6.2) will not respond a 302 to the upload_sketch_silent request, thus avoiding the fallback to ssh method (which would work otherwise)

@sandeepmistry
Copy link
Contributor Author

@facchinm yes, it responds with a 404, and we fallback to SSH mode.

@facchinm facchinm removed their assignment Oct 3, 2018
@matteosuppo matteosuppo force-pushed the devel branch 4 times, most recently from fee3d17 to b0b3b31 Compare April 6, 2020 15:52
@zmoog
Copy link
Contributor

zmoog commented Jan 15, 2021

The support for Yun Shield was never completed, so we're closing this PR. RIP.

@zmoog zmoog closed this Jan 15, 2021
@per1234 per1234 added topic: code Related to content of the project itself conclusion: declined Will not be worked on type: imperfection Perceived defect in any part of project labels Jul 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
conclusion: declined Will not be worked on topic: code Related to content of the project itself type: imperfection Perceived defect in any part of project
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants