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

Support passing Content-Length to external headers on fsread1 #19861

Closed
jelly opened this issue Jan 19, 2024 · 4 comments · Fixed by #19889
Closed

Support passing Content-Length to external headers on fsread1 #19861

jelly opened this issue Jan 19, 2024 · 4 comments · Fixed by #19889

Comments

@jelly
Copy link
Member

jelly commented Jan 19, 2024

In Cockpit navigator we want to offer the option to download a file, this isn't too hard with an external channel:

    const query = window.btoa(JSON.stringify({
        payload: "fsread1",
        binary: "raw",
        path: `${currentPath}/${selected.name}`,
        superuser: "try",
        external: {
            "content-disposition": `attachment; filename="${selected.name}"`,
            "content-type": "application/octet-stream",
            "content-length": Number(selected.size),
        }
    }));

However cockpit-ws does not cockpit_web_service_parse_external ignores content-length and without the content-length a big download won't show the remaining time until it's downloaded. I think the easiest solution is to just allow setting this header, teaching cockpit-ws how to get the filesize seems a little bit daunting.

Background info: cockpit-project/cockpit-files#175 (comment)

@jelly
Copy link
Member Author

jelly commented Jan 19, 2024

@martinpitt @allisonkarlitskaya would love your input here :)

@Faizan-Alam-1
Copy link

Faizan-Alam-1 commented Jan 20, 2024

@jelly Hey , can I take this task?

@jelly
Copy link
Member Author

jelly commented Jan 20, 2024

@jelly Hey , can I take this task?

There is nothing decided yet, this is purely a research issue.

@jelly
Copy link
Member Author

jelly commented Jan 24, 2024

Idea from @allisonkarlitskaya make the ready message in fsread1 return the content-length and let cockpit-ws send that back to the client.

jelly added a commit to jelly/cockpit that referenced this issue Jan 25, 2024
Cockpit navigator and SOS report offer a file download option,
downloading a file in the browser shows the download speed but no
estimation of how long it takes. This is due to the lack of the
Content-Length header which could be added via the external channel
options however the `fsread1` channel already has all the information.

The `fsread1` channel now emits a `size-hint` in the ready message which
cockpit-ws picks up and adds a Content-Length header. The header is only
included for the binary channel mode.

Closes: cockpit-project#19861
jelly added a commit to jelly/cockpit that referenced this issue Jan 25, 2024
Cockpit navigator and SOS report offer a file download option,
downloading a file in the browser shows the download speed but no
estimation of how long it takes. This is due to the lack of the
Content-Length header which could be added via the external channel
options however the `fsread1` channel already has all the information.

The `fsread1` channel now emits a `size-hint` in the ready message which
cockpit-ws picks up and adds a Content-Length header. The header is only
included for the binary channel mode.

Closes: cockpit-project#19861
jelly added a commit to jelly/cockpit that referenced this issue Jan 25, 2024
Cockpit navigator and SOS report offer a file download option,
downloading a file in the browser shows the download speed but no
estimation of how long it takes. This is due to the lack of the
Content-Length header which could be added via the external channel
options however the `fsread1` channel already has all the information.

The `fsread1` channel now emits a `size-hint` in the ready message which
cockpit-ws picks up and adds a Content-Length header. The header is only
included for the binary channel mode.

Closes: cockpit-project#19861
jelly added a commit to jelly/cockpit that referenced this issue Jan 26, 2024
Cockpit navigator and SOS report offer a file download option,
downloading a file in the browser shows the download speed but no
estimation of how long it takes. This is due to the lack of the
Content-Length header which could be added via the external channel
options however the `fsread1` channel already has all the information.

The `fsread1` channel now emits a `size-hint` in the ready message which
cockpit-ws picks up and adds a Content-Length header. The header is only
included for the binary channel mode.

Closes: cockpit-project#19861
jelly added a commit to jelly/cockpit that referenced this issue Jan 26, 2024
Cockpit navigator and SOS report offer a file download option,
downloading a file in the browser shows the download speed but no
estimation of how long it takes. This is due to the lack of the
Content-Length header which could be added via the external channel
options however the `fsread1` channel already has all the information.

The `fsread1` channel now emits a `size-hint` in the ready message which
cockpit-ws picks up and adds a Content-Length header. The header is only
included for the binary channel mode.

Closes: cockpit-project#19861
jelly added a commit to jelly/cockpit that referenced this issue Jan 26, 2024
Cockpit navigator and SOS report offer a file download option,
downloading a file in the browser shows the download speed but no
estimation of how long it takes. This is due to the lack of the
Content-Length header which could be added via the external channel
options however the `fsread1` channel already has all the information.

The `fsread1` channel now emits a `size-hint` in the ready message which
cockpit-ws picks up and adds a Content-Length header. The header is only
included for the binary channel mode.

Closes: cockpit-project#19861
jelly added a commit to jelly/cockpit that referenced this issue Jan 26, 2024
Cockpit navigator and SOS report offer a file download option,
downloading a file in the browser shows the download speed but no
estimation of how long it takes. This is due to the lack of the
Content-Length header which could be added via the external channel
options however the `fsread1` channel already has all the information.

The `fsread1` channel now emits a `size-hint` in the ready message which
cockpit-ws picks up and adds a Content-Length header. The header is only
included for the binary channel mode.

Closes: cockpit-project#19861
jelly added a commit to jelly/cockpit that referenced this issue Jan 29, 2024
Cockpit navigator and SOS report offer a file download option,
downloading a file in the browser shows the download speed but no
estimation of how long it takes. This is due to the lack of the
Content-Length header which could be added via the external channel
options however the `fsread1` channel already has all the information.

The `fsread1` channel now emits a `size-hint` in the ready message which
cockpit-ws picks up and adds a Content-Length header. The header is only
included for the binary channel mode.

Closes: cockpit-project#19861
jelly added a commit to jelly/cockpit that referenced this issue Jan 29, 2024
Cockpit navigator and SOS report offer a file download option,
downloading a file in the browser shows the download speed but no
estimation of how long it takes. This is due to the lack of the
Content-Length header which could be added via the external channel
options however the `fsread1` channel already has all the information.

The `fsread1` channel now emits a `size-hint` in the ready message which
cockpit-ws picks up and adds a Content-Length header. The header is only
included for the binary channel mode.

Closes: cockpit-project#19861
jelly added a commit to jelly/cockpit that referenced this issue Jan 29, 2024
Cockpit navigator and SOS report offer a file download option,
downloading a file in the browser shows the download speed but no
estimation of how long it takes. This is due to the lack of the
Content-Length header which could be added via the external channel
options however the `fsread1` channel already has all the information.

The `fsread1` channel now emits a `size-hint` in the ready message which
cockpit-ws picks up and adds a Content-Length header. The header is only
included for the binary channel mode.

Closes: cockpit-project#19861
jelly added a commit to jelly/cockpit that referenced this issue Jan 29, 2024
Cockpit navigator and SOS report offer a file download option,
downloading a file in the browser shows the download speed but no
estimation of how long it takes. This is due to the lack of the
Content-Length header which could be added via the external channel
options however the `fsread1` channel already has all the information.

The `fsread1` channel now emits a `size-hint` in the ready message which
cockpit-ws picks up and adds a Content-Length header. The header is only
included for the binary channel mode.

Closes: cockpit-project#19861
jelly added a commit to jelly/cockpit that referenced this issue Jan 29, 2024
Cockpit navigator and SOS report offer a file download option,
downloading a file in the browser shows the download speed but no
estimation of how long it takes. This is due to the lack of the
Content-Length header which could be added via the external channel
options however the `fsread1` channel already has all the information.

The `fsread1` channel now emits a `size-hint` in the ready message which
cockpit-ws picks up and adds a Content-Length header. The header is only
included for the binary channel mode.

Closes: cockpit-project#19861
jelly added a commit to jelly/cockpit that referenced this issue Jan 29, 2024
Cockpit navigator and SOS report offer a file download option,
downloading a file in the browser shows the download speed but no
estimation of how long it takes. This is due to the lack of the
Content-Length header which could be added via the external channel
options however the `fsread1` channel already has all the information.

The `fsread1` channel now emits a `size-hint` in the ready message which
cockpit-ws picks up and adds a Content-Length header. The header is only
included for the binary channel mode.

Closes: cockpit-project#19861
jelly added a commit to jelly/cockpit that referenced this issue Jan 30, 2024
Cockpit navigator and SOS report offer a file download option,
downloading a file in the browser shows the download speed but no
estimation of how long it takes. This is due to the lack of the
Content-Length header which could be added via the external channel
options however the `fsread1` channel already has all the information.

The `fsread1` channel now emits a `size-hint` in the ready message which
cockpit-ws picks up and adds a Content-Length header. The header is only
included for the binary channel mode.

Closes: cockpit-project#19861
jelly added a commit that referenced this issue Jan 30, 2024
Cockpit navigator and SOS report offer a file download option,
downloading a file in the browser shows the download speed but no
estimation of how long it takes. This is due to the lack of the
Content-Length header which could be added via the external channel
options however the `fsread1` channel already has all the information.

The `fsread1` channel now emits a `size-hint` in the ready message which
cockpit-ws picks up and adds a Content-Length header. The header is only
included for the binary channel mode.

Closes: #19861
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants