"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files
Go azure-blobazure-blob-storageazure-filesbackblaze-b2cloud-storagedropboxencryptionftpfuse-filesystemgogolanggoogle-cloud-storagegoogle-driveonedriveopenstack-swiftrclones3sftpsyncwebdav
copyurl: add tests for the option to honor the HTTP header filename directive
buengeseac0dc9922ee9
diff --git a/fs/operations/operations_test.go b/fs/operations/operations_test.goindex 545bcbe4d..04b26e8b8 100644--- a/fs/operations/operations_test.go+++ b/fs/operations/operations_test.go@@ -729,10 +729,15 @@ func TestCopyURL(t *testing.T) {// check when reading from regular HTTP serverstatus := 0+ nameHeader := false+ headerFilename := "headerfilename.txt"handler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {if status != 0 {http.Error(w, "an error ocurred", status)}+ if nameHeader {+ w.Header().Set("Content-Disposition", `attachment; filename="folder\`+headerFilename+`"`)+ }_, err := w.Write([]byte(contents))assert.NoError(t, err)})@@ -757,10 +762,22 @@ func TestCopyURL(t *testing.T) {assert.Equal(t, int64(len(contents)), o.Size())assert.Equal(t, urlFileName, o.Remote())+ // Check header file naming+ nameHeader = true+ o, err = operations.CopyURL(ctx, r.Fremote, "", ts.URL, true, true, false)+ require.NoError(t, err)+ assert.Equal(t, int64(len(contents)), o.Size())+ assert.Equal(t, headerFilename, o.Remote())+// Check auto file naming when url without file name_, err = operations.CopyURL(ctx, r.Fremote, "file1", ts.URL, true, false, false)require.Error(t, err)+ // Check header file naming without header set+ nameHeader = false+ _, err = operations.CopyURL(ctx, r.Fremote, "file1", ts.URL, true, true, false)+ require.Error(t, err)+// Check an error is returned for a 404status = http.StatusNotFoundo, err = operations.CopyURL(ctx, r.Fremote, "file1", ts.URL, false, false, false)@@ -779,7 +796,7 @@ func TestCopyURL(t *testing.T) {o, err = operations.CopyURL(ctx, r.Fremote, "file2", tss.URL, false, false, false)require.NoError(t, err)assert.Equal(t, int64(len(contents)), o.Size())- fstest.CheckListingWithPrecision(t, r.Fremote, []fstest.Item{file1, file2, fstest.NewItem(urlFileName, contents, t1)}, nil, fs.ModTimeNotSupported)+ fstest.CheckListingWithPrecision(t, r.Fremote, []fstest.Item{file1, file2, fstest.NewItem(urlFileName, contents, t1), fstest.NewItem(headerFilename, contents, t1)}, nil, fs.ModTimeNotSupported)}func TestCopyURLToWriter(t *testing.T) {