From c5250e529e4263c1c8556d34456989de5155b497 Mon Sep 17 00:00:00 2001 From: andreimarcu Date: Tue, 6 Oct 2015 00:31:09 -0400 Subject: [PATCH] Headers are now Linx-.. instead of X-... --- delete.go | 2 +- server_test.go | 14 +++++++------- static/js/upload.js | 2 +- upload.go | 9 +++------ 4 files changed, 12 insertions(+), 15 deletions(-) diff --git a/delete.go b/delete.go index 521b277..e70bf22 100644 --- a/delete.go +++ b/delete.go @@ -10,7 +10,7 @@ import ( ) func deleteHandler(c web.C, w http.ResponseWriter, r *http.Request) { - requestKey := r.Header.Get("X-Delete-Key") + requestKey := r.Header.Get("Linx-Delete-Key") filename := c.URLParams["name"] filePath := path.Join(Config.filesDir, filename) diff --git a/server_test.go b/server_test.go index 31e690b..4fc426f 100644 --- a/server_test.go +++ b/server_test.go @@ -113,7 +113,7 @@ func TestPutRandomizedUpload(t *testing.T) { t.Fatal(err) } - req.Header.Set("X-Randomized-Barename", "yes") + req.Header.Set("Linx-Randomize", "yes") goji.DefaultMux.ServeHTTP(w, req) @@ -132,7 +132,7 @@ func TestPutEmptyUpload(t *testing.T) { t.Fatal(err) } - req.Header.Set("X-Randomized-Barename", "yes") + req.Header.Set("Linx-Randomize", "yes") goji.DefaultMux.ServeHTTP(w, req) @@ -194,7 +194,7 @@ func TestPutRandomizedJSONUpload(t *testing.T) { } req.Header.Set("Accept", "application/json") - req.Header.Set("X-Randomized-Barename", "yes") + req.Header.Set("Linx-Randomize", "yes") goji.DefaultMux.ServeHTTP(w, req) @@ -228,7 +228,7 @@ func TestPutExpireJSONUpload(t *testing.T) { } req.Header.Set("Accept", "application/json") - req.Header.Set("X-File-Expiry", "600") + req.Header.Set("Linx-Expiry", "600") goji.DefaultMux.ServeHTTP(w, req) @@ -275,7 +275,7 @@ func TestPutAndDelete(t *testing.T) { // Delete it w = httptest.NewRecorder() req, err = http.NewRequest("DELETE", "/"+myjson.Filename, nil) - req.Header.Set("X-Delete-Key", myjson.Delete_Key) + req.Header.Set("Linx-Delete-Key", myjson.Delete_Key) goji.DefaultMux.ServeHTTP(w, req) if w.Code != 200 { @@ -319,7 +319,7 @@ func TestPutAndSpecificDelete(t *testing.T) { } req.Header.Set("Accept", "application/json") - req.Header.Set("X-Delete-Key", "supersecret") + req.Header.Set("Linx-Delete-Key", "supersecret") goji.DefaultMux.ServeHTTP(w, req) @@ -331,7 +331,7 @@ func TestPutAndSpecificDelete(t *testing.T) { // Delete it w = httptest.NewRecorder() req, err = http.NewRequest("DELETE", "/"+myjson.Filename, nil) - req.Header.Set("X-Delete-Key", "supersecret") + req.Header.Set("Linx-Delete-Key", "supersecret") goji.DefaultMux.ServeHTTP(w, req) if w.Code != 200 { diff --git a/static/js/upload.js b/static/js/upload.js index 6656de0..60ef981 100644 --- a/static/js/upload.js +++ b/static/js/upload.js @@ -60,7 +60,7 @@ Dropzone.options.dropzone = { deleteAction.addEventListener('click', function(ev) { xhr = new XMLHttpRequest(); xhr.open("DELETE", resp.url, true); - xhr.setRequestHeader("X-Delete-Key", resp.delete_key); + xhr.setRequestHeader("Linx-Delete-Key", resp.delete_key); xhr.onreadystatechange = function(file) { if (xhr.readyState == 4 && xhr.status === 200) { var text = document.createTextNode("Deleted "); diff --git a/upload.go b/upload.go index 861c03b..3864896 100644 --- a/upload.go +++ b/upload.go @@ -172,17 +172,14 @@ func uploadRemote(c web.C, w http.ResponseWriter, r *http.Request) { } func uploadHeaderProcess(r *http.Request, upReq *UploadRequest) { - // For legacy reasons - if r.Header.Get("X-Randomized-Filename") == "yes" { - upReq.randomBarename = true - } else if r.Header.Get("X-Randomized-Barename") == "yes" { + if r.Header.Get("Linx-Randomize") == "yes" { upReq.randomBarename = true } - upReq.deletionKey = r.Header.Get("X-Delete-Key") + upReq.deletionKey = r.Header.Get("Linx-Delete-Key") // Get seconds until expiry. Non-integer responses never expire. - expStr := r.Header.Get("X-File-Expiry") + expStr := r.Header.Get("Linx-Expiry") upReq.expiry = parseExpiry(expStr) }