1
0
Fork 0
mirror of https://github.com/binwiederhier/ntfy.git synced 2025-05-20 13:58:21 +02:00

Allow HEAD requests for file attachments

This commit is contained in:
Philipp Heckel 2022-06-10 21:33:39 -04:00
parent 10c89b2e55
commit 2b42cea1a3
2 changed files with 22 additions and 9 deletions

View file

@ -1026,12 +1026,19 @@ func TestServer_PublishAttachment(t *testing.T) {
require.Equal(t, "", msg.Sender) // Should never be returned
require.FileExists(t, filepath.Join(s.config.AttachmentCacheDir, msg.ID))
// GET
path := strings.TrimPrefix(msg.Attachment.URL, "http://127.0.0.1:12345")
response = request(t, s, "GET", path, "", nil)
require.Equal(t, 200, response.Code)
require.Equal(t, "5000", response.Header().Get("Content-Length"))
require.Equal(t, content, response.Body.String())
// HEAD
response = request(t, s, "HEAD", path, "", nil)
require.Equal(t, 200, response.Code)
require.Equal(t, "5000", response.Header().Get("Content-Length"))
require.Equal(t, "", response.Body.String())
// Slightly unrelated cross-test: make sure we add an owner for internal attachments
size, err := s.messageCache.AttachmentBytesUsed("9.9.9.9") // See request()
require.Nil(t, err)