@@ -119,7 +119,7 @@ func ensureUtf8(s string, fromEncoding string) string {
119119 return s2
120120}
121121
122- func serveFile (parts ParsedParts , w http.ResponseWriter , r * http.Request ) {
122+ func serveFile (parts ParsedParts , w http.ResponseWriter , r * http.Request ) ( work bool ) {
123123
124124 ipPort := fmt .Sprintf ("%s:%d" , parts .ip .String (), parts .port )
125125 //println(strings.Trim(m.GetParamU(1,""),"\x01"))
@@ -128,13 +128,13 @@ func serveFile(parts ParsedParts, w http.ResponseWriter, r *http.Request) {
128128 if parts .ip == nil {
129129 w .WriteHeader (http .StatusNotFound )
130130 w .Write ([]byte ("404 - You tried" ))
131- return
131+ return false
132132 }
133133 conn , err := net .Dial ("tcp" , ipPort )
134134 if err != nil {
135135 w .WriteHeader (http .StatusBadGateway )
136136 w .Write ([]byte (err .Error ()))
137- return
137+ return false
138138 }
139139
140140 pr , pw := io .Pipe ()
@@ -170,6 +170,7 @@ func serveFile(parts ParsedParts, w http.ResponseWriter, r *http.Request) {
170170 // // write json data to the PipeReader through the PipeWriter
171171 //
172172 // }()
173+ return true
173174
174175
175176}
@@ -393,10 +394,11 @@ func (s *Server) InitDispatch() {
393394 parts := s .fileNames [name ]
394395
395396 //call serveFile here
396- serveFile (parts , w , r ) //removed go keyword this could mean servFile can only happen once
397+ if serveFile (parts , w , r ){ //removed go keyword this could mean servFile can only happen once
397398
398399 //destroy route
399400 s .Destroy (parts )
401+ }
400402
401403 }).Methods ("GET" )
402404}
0 commit comments