Skip to content

Commit

Permalink
Merge branch 'master' into feature/upload
Browse files Browse the repository at this point in the history
  • Loading branch information
bassosimone committed Apr 12, 2019
2 parents 8dc3778 + a0056db commit 8c56bd6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
7 changes: 7 additions & 0 deletions ndt-server.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import (
"os/signal"
"syscall"

"github.com/gorilla/websocket"

"github.com/m-lab/go/prometheusx"

"github.com/m-lab/go/flagx"
Expand Down Expand Up @@ -167,6 +169,11 @@ func main() {
ndt7Mux.Handle("/static/", http.StripPrefix("/static", http.FileServer(http.Dir("html"))))
ndt7Handler := &handler.Handler{
DataDir: *dataDir,
Upgrader: websocket.Upgrader{
CheckOrigin: func(r *http.Request) bool {
return true // Allow cross origin resource sharing
},
},
}
ndt7Mux.Handle(
spec.DownloadURLPath,
Expand Down
5 changes: 4 additions & 1 deletion ndt7/handler/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package handler

import (
"context"
"fmt"
"net/http"

"github.com/gorilla/websocket"
Expand Down Expand Up @@ -53,7 +54,9 @@ func (h Handler) downloadOrUpload(writer http.ResponseWriter, request *http.Requ
headers.Add("Sec-WebSocket-Protocol", spec.SecWebSocketProtocol)
conn, err := h.Upgrader.Upgrade(writer, request, headers)
if err != nil {
warnAndClose(writer, "downloadOrUpload: cannnot UPGRADE to WebSocket")
warnAndClose(writer, fmt.Sprintf(
"downloadOrUpload: cannnot UPGRADE to WebSocket: %s", err,
))
return
}
// TODO(bassosimone): an error before this point means that the *os.File
Expand Down

0 comments on commit 8c56bd6

Please sign in to comment.