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

Wrong Content-Type in HTTP API #7726

Closed
nullinger opened this issue Apr 5, 2024 · 5 comments
Closed

Wrong Content-Type in HTTP API #7726

nullinger opened this issue Apr 5, 2024 · 5 comments

Comments

@nullinger
Copy link

The associated forum post URL from https://forum.rclone.org

https://forum.rclone.org/t/wrong-content-type-in-http-api/45420

What is the problem you are having with rclone?

The HTTP API always returns the Content-Type text/plain; charset=utf-8 instead of application/json.

What is your rclone version (output from rclone version)

rclone v1.66.0
- os/version: alpine 3.19.1 (64 bit)
- os/kernel: 5.15.0-101-generic (x86_64)
- os/type: linux
- os/arch: amd64
- go/version: go1.22.1
- go/linking: static
- go/tags: none

Which OS you are using and how many bits (e.g. Windows 7, 64 bit)

Windows and Linux (Docker), both 64 bit

Which cloud storage system are you using? (e.g. Google Drive)

Not relevant

The command you were trying to run (e.g. rclone copy /tmp remote:tmp)

curl -v -X POST http://localhost:5572/core/stats

A log from the command with the -vv flag (e.g. output from rclone -vv copy /tmp remote:tmp)

rclone    | 2024/04/03 22:49:45 DEBUG : rclone: Version "v1.66.0" starting with parameters ["rclone" "rcd" "--rc-addr" ":5572" "--rc-no-auth" "-vv"]
rclone    | 2024/04/03 22:49:45 NOTICE: Serving remote control on http://[::]:5572/
rclone    | 2024/04/03 22:49:56 DEBUG : rc: "core/stats": with parameters map[]
rclone    | 2024/04/03 22:49:56 DEBUG : rc: "core/stats": reply map[bytes:0 checks:0 deletedDirs:0 deletes:0 elapsedTime:10.985591033 errors:0 eta:<nil> fatalError:false renames:0 retryError:false serverSideCopies:0 serverSideCopyBytes:0 serverSideMoveBytes:0 serverSideMoves:0 speed:0 totalBytes:0 totalChecks:0 totalTransfers:0 transferTime:0 transfers:0]: <nil>

How to use GitHub

  • Please use the 👍 reaction to show that you are affected by the same issue.
  • Please don't comment if you have no relevant information to add. It's just extra noise for everyone subscribed to this issue.
  • Subscribe to receive notifications on status change and new comments.
@ncw
Copy link
Member

ncw commented Apr 5, 2024

Do you want to have a go at fixing this @nullinger ?

@nullinger
Copy link
Author

Hm,

I think that you are overestimating my Go knowledge 😟

The Content-Type seems to be set here but I don’t know where the function is called:

headers["Content-Type"] = opts.ContentType

@ncw
Copy link
Member

ncw commented Apr 5, 2024

Maybe @KDreynolds would like to have a go at this? It will end up being a one two line change, but which line to change is the problem!

I think anywhere you see rc.WriteJSON in this file (there are two places) should probably set the Content-Type just before. Ideally we should check this in the tests too.

err = rc.WriteJSON(w, params)

@KDreynolds
Copy link
Contributor

Sounds good, I'll take a crack at this. Thanks!

KDreynolds pushed a commit to KDreynolds/rclone that referenced this issue Apr 5, 2024
@KDreynolds
Copy link
Contributor

ok I pushed PR #7730 for this. Good chance I need to do some go fmt or something, LMK.

KDreynolds pushed a commit to KDreynolds/rclone that referenced this issue Apr 8, 2024
KDreynolds pushed a commit to KDreynolds/rclone that referenced this issue Apr 8, 2024
KDreynolds pushed a commit to KDreynolds/rclone that referenced this issue Apr 10, 2024
KDreynolds pushed a commit to KDreynolds/rclone that referenced this issue Apr 10, 2024
@ncw ncw closed this as completed in 47cbddb Apr 13, 2024
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

3 participants