File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ package server
33import (
44 "encoding/json"
55 "net/http"
6+ "strconv"
67 "time"
78
89 "github.com/codeshelldev/gotl/pkg/logger"
@@ -40,14 +41,21 @@ func httpHandler(w http.ResponseWriter, req *http.Request) {
4041 "client_id" : clientID ,
4142 }
4243
43- w .Header ().Set ("Content-Type" , "application/json" )
44- json .NewEncoder (w ).Encode (resp )
44+ respBytes , err := json .Marshal (resp )
45+
46+ if err != nil {
47+ http .Error (w , "Internal Server Error" , http .StatusInternalServerError )
48+ }
4549
4650 logger .Debug ("Sending client_id to client" )
4751
52+ w .Header ().Set ("Content-Type" , "application/json" )
53+ w .Header ().Set ("Content-Length" , strconv .Itoa (len (respBytes )))
54+ w .Write (respBytes )
55+
4856 f , ok := w .(http.Flusher )
49- if ok {
50- f .Flush ()
57+ if ok {
58+ f .Flush ()
5159 }
5260
5361 logger .Debug ("Waiting for client to establish websocket connection" )
You can’t perform that action at this time.
0 commit comments