Browse Source

Headers are now Linx-.. instead of X-...

pull/41/head
andreimarcu 9 years ago
parent
commit
c5250e529e
  1. 2
      delete.go
  2. 14
      server_test.go
  3. 2
      static/js/upload.js
  4. 9
      upload.go

2
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)

14
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 {

2
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 ");

9
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)
}

Loading…
Cancel
Save