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

Add X-Url-Delete-* headers to POST handler #435

Merged
merged 6 commits into from Mar 2, 2022

Conversation

anihm136
Copy link
Contributor

@anihm136 anihm136 commented Nov 11, 2021

Fixes #419
Adds X-Url-Delete headers to the post handler. Since the post handler currently supports multiple file uploads (as multipart file form), currently the header is postfixed with the token of the file to create a unique delete token for each file (any better suggestions for handling this can be implemented)

@aspacca
Copy link
Collaborator

aspacca commented Nov 11, 2021

any better suggestions for handling this can be implemented

We could send multiple X-Url-Delete headers, with every delete url.
Replacing
w.Header().Set("X-Url-Delete-"+token, resolveURL(r, deleteURL, s.proxyPort))
with
w.Header().Add("X-Url-Delete", resolveURL(r, deleteURL, s.proxyPort))
should be enough

The delete url already contains the full get url including the filename https://transfer.sh/QMXz5o/hello.txt/e199GfHtnsyC so users should be able to match

server/handlers.go Outdated Show resolved Hide resolved
@aspacca
Copy link
Collaborator

aspacca commented Dec 15, 2021

@anihm136 are you still going to work on this?

otherwise I will create a new branch with the fix, thanks :)

@anihm136
Copy link
Contributor Author

Sorry, I'm a little packed right now. Please go ahead with the fix

@anihm136
Copy link
Contributor Author

Hey @aspacca I have some time on my hands for the next week or so. Shall I go ahead and finish this?

@aspacca
Copy link
Collaborator

aspacca commented Jan 16, 2022

@anihm136 thanks

could you fix the conflict with main branch?

there was some refactoring since you opened your branch

@anihm136
Copy link
Contributor Author

Should be done

@aspacca
Copy link
Collaborator

aspacca commented Jan 27, 2022

@anihm136 can you fix the linting?

thanks

@anihm136
Copy link
Contributor Author

Done. Unfortunately I missed it because my editor uses the --fast flag with the linter, which missed the error

deleteURL, _ := url.Parse(path.Join(s.proxyPath, token, filename, metadata.DeletionToken))
w.Header().Add("X-Url-Delete", resolveURL(r, deleteURL, s.proxyPort))
responseBody += fmt.Sprintln( getURL(r, s.proxyPort).ResolveReference(relativeURL).String())
s.cleanTmpFile(file)
Copy link
Collaborator

Choose a reason for hiding this comment

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

We should not need this call here, due to the defer in L319.

@aspacca aspacca merged commit 597554a into dutchcoders:main Mar 2, 2022
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.

No x-url-delete header when sending POST request
3 participants