android-library icon indicating copy to clipboard operation
android-library copied to clipboard

Fix issues with HTTP redirects and file upload

Open z3ntu opened this issue 3 years ago • 8 comments

Firstly the test setup:

  • Nextcloud running behind a reverse proxy (e.g. Traefik) configured for HTTP only
  • Configure Nextcloud app to connect to that server
  • Configure https on reverse proxy, enable http -> https redirects on the reverse proxy
    • Traefik uses the HTTP 308 status code to redirect clients
  • Try to upload some pictures via the Auto upload feature

Previously this resulted in the following notification being sent to the user: Screenshot_20201003-185029_2

With these patches I can successfully upload pictures to my server.

See commit messages for more details.

z3ntu avatar Oct 03 '20 16:10 z3ntu

Lint

TypemasterPR
Warnings11
Errors00

SpotBugs (new)

Warning TypeNumber
Bad practice Warnings14
Correctness Warnings38
Internationalization Warnings6
Malicious code vulnerability Warnings7
Multithreaded correctness Warnings3
Performance Warnings17
Security Warnings1
Dodgy code Warnings40
Total126

SpotBugs (master)

Warning TypeNumber
Bad practice Warnings14
Correctness Warnings38
Internationalization Warnings6
Malicious code vulnerability Warnings7
Multithreaded correctness Warnings3
Performance Warnings17
Security Warnings1
Dodgy code Warnings40
Total126

nextcloud-android-bot avatar Oct 03 '20 17:10 nextcloud-android-bot

Codecov Report

Merging #514 into master will increase coverage by 0.06%. The diff coverage is 0.00%.

@@            Coverage Diff             @@
##           master     #514      +/-   ##
==========================================
+ Coverage   39.76%   39.82%   +0.06%     
==========================================
  Files         137      137              
  Lines        5970     5978       +8     
  Branches      784      789       +5     
==========================================
+ Hits         2374     2381       +7     
- Misses       3235     3238       +3     
+ Partials      361      359       -2     
Impacted Files Coverage Δ
.../main/java/com/nextcloud/common/NextcloudClient.kt 50.76% <0.00%> (-2.46%) :arrow_down:
...om/owncloud/android/lib/common/OwnCloudClient.java 38.95% <0.00%> (-0.93%) :arrow_down:
...ources/files/ChunkedFileUploadRemoteOperation.java 22.76% <0.00%> (-0.19%) :arrow_down:
...d/lib/common/operations/RemoteOperationResult.java 43.29% <0.00%> (+1.21%) :arrow_up:
...lib/resources/files/RemoveFileRemoteOperation.java 84.21% <0.00%> (+15.78%) :arrow_up:

codecov[bot] avatar Oct 03 '20 17:10 codecov[bot]

Sorry for coming back this late… Permanent redirects should already be handled via login, so that the real redirected url is stored. This way we do not have to do multiple hops per each request.

Have you changed your system after installing the app?

tobiasKaminsky avatar Nov 04 '20 11:11 tobiasKaminsky

Yes, as mentioned in the original message, the permanent redirect was added after the initial login leading to the issues I was seeing.

z3ntu avatar Nov 04 '20 11:11 z3ntu

Hm. But this then means, that every request is done to times: first against old, get redirect, then to new url. As the library does not store the base url, this should be handled on app side, to update it, once it sees a permanet redirect.

Do you have an idea how to inform the client?

tobiasKaminsky avatar Nov 06 '20 06:11 tobiasKaminsky

Right.. But as non-HTTP 308 redirect statuses already redirect properly I don't think solving this is in the scope of this - and this PR is just adjusting existing redirect code (for the most part).

Also I'm too unfamiliar with the Nextcloud App codebase with regard to updating the base url.

z3ntu avatar Nov 08 '20 13:11 z3ntu

I will have a deeper look into this soon. Currently I am a bit too busy, but I will not forget your PR.

tobiasKaminsky avatar Nov 09 '20 07:11 tobiasKaminsky

but I will not forget your PR.

Safe to say this was forgotten.

I'll leave this open but my setup has changed in the meantime so I'm not directly interested in this anymore.

z3ntu avatar Apr 26 '23 17:04 z3ntu