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

fixes #388 #389

Closed
Closed

Conversation

tim3trick
Copy link

Responses to the pre-finish hook will be passed to the client as custom header "X-pre-finish-response"

Julian Berkner added 3 commits May 27, 2020 10:14
Responses to the pre-finish hook will be passed to the client as custom header "X-pre-finish-response"
@Acconut
Copy link
Member

Acconut commented Jun 10, 2020

Thank you for the PR but I see a two problems withthis approach:

  1. This is a breaking API change since the PreFinishCallback's signature changed.
  2. Calling the header X-pre-finish-response is not a good fit. It exposes implementation details of tusd (i.e. that tusd uses hooks internally and that a pre-finish hook provided this value) which are not relevant to the world outside of tusd. Also, I can image a situation where people would like to change the header's name.

What do you think?

@tim3trick
Copy link
Author

Thank you for your response,

  1. I agree, maybe it could be moved to yet another hook, that is built for this specific requirement? (Beside from just bumping the major version)

  2. I agree again. How about describing an interface like
    {"header": "x-my-custom-header", "content": any content} and make tusd send the header (maybe after checking the name not to collide with tusds headers) with the given content?

When going with a new hook, how could that hook be named? pre-response?

@Acconut
Copy link
Member

Acconut commented Jun 10, 2020

I am not sure I understand the idea of the pre-response hook here. When should it be invoked? Before every response that is sent by tusd?

@tim3trick
Copy link
Author

My usecase is that I have to pass data to the client, which is basically based on the file itself, so I have to pass data as soon as the upload is complete (and before the connection to tusd is closed obviously). My usecase would be satisfied when the hook is called once (the pre-finish hook would be/is a perfect fit), right before everything is finished. For a broader usecase it could be a hook that is called each time before data is sent to the client and I build the hook to do nothing except for the last time, but as the hook should be blocking, this could add up to some serious delay...

@Acconut
Copy link
Member

Acconut commented Jun 19, 2020

My usecase is that I have to pass data to the client

I can understand the need for that. However, tus and therefore tusd (especially the hook system) has been designed with uni-directional data flow from the client to the server and not vice versa. That's why tusd has no such feature yet and I am unsure if there is good/elegant solution to implement data flow from hooks to the client at the current time. I have ideas to rework the hook system to be more powerful but there is no timeline yet.

For a broader usecase it could be a hook that is called each time before data is sent to the client and I build the hook to do nothing except for the last time, but as the hook should be blocking, this could add up to some serious delay...

Yes, those delays sound like a serious problem and I would like to avoid that.

@Acconut
Copy link
Member

Acconut commented Aug 23, 2023

The v2 release will contain features to customize the response from tusd and set a custom body and headers: #672

@Acconut Acconut closed this Aug 23, 2023
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

Successfully merging this pull request may close these issues.

2 participants