@@ -213,6 +213,7 @@ func (i *gatewayHandler) getOrHeadHandler(w http.ResponseWriter, r *http.Request
213
213
break
214
214
}
215
215
}
216
+ logger .Debugw ("sub-path" , "prefix" , prefix )
216
217
}
217
218
218
219
// HostnameOption might have constructed an IPNS/IPFS path using the Host header.
@@ -247,8 +248,8 @@ func (i *gatewayHandler) getOrHeadHandler(w http.ResponseWriter, r *http.Request
247
248
}
248
249
249
250
redirectURL := gopath .Join ("/" , prefix , u .Scheme , u .Host , path )
250
- http .Redirect (w , r , redirectURL , http .StatusMovedPermanently )
251
251
logger .Debugw ("received an uri param, redirect" , "to" , redirectURL , "status" , http .StatusMovedPermanently )
252
+ http .Redirect (w , r , redirectURL , http .StatusMovedPermanently )
252
253
return
253
254
}
254
255
@@ -269,7 +270,7 @@ func (i *gatewayHandler) getOrHeadHandler(w http.ResponseWriter, r *http.Request
269
270
if prefix == "" && fixupSuperfluousNamespace (w , urlPath , r .URL .RawQuery ) {
270
271
// the error was due to redundant namespace, which we were able to fix
271
272
// by returning error/redirect page, nothing left to do here
272
- logger .Debugw ("redundant namespace, fixed by returning error/redirect page" )
273
+ logger .Debugw ("redundant namespace, returning error/redirect page" )
273
274
return
274
275
}
275
276
// unable to fix path, returning error
@@ -286,6 +287,7 @@ func (i *gatewayHandler) getOrHeadHandler(w http.ResponseWriter, r *http.Request
286
287
return
287
288
default :
288
289
if i .servePretty404IfPresent (w , r , parsedPath ) {
290
+ logger .Debugw ("serve pretty 404 if present" )
289
291
return
290
292
}
291
293
@@ -352,6 +354,8 @@ func (i *gatewayHandler) getOrHeadHandler(w http.ResponseWriter, r *http.Request
352
354
} else {
353
355
name = getFilename (urlPath )
354
356
}
357
+
358
+ logger .Debugw ("serve file" , "name" , name )
355
359
i .serveFile (w , r , name , modtime , f )
356
360
return
357
361
}
@@ -376,8 +380,8 @@ func (i *gatewayHandler) getOrHeadHandler(w http.ResponseWriter, r *http.Request
376
380
}
377
381
378
382
redirectURL := originalUrlPath + suffix
383
+ logger .Debugw ("serving index.html file" , "to" , redirectURL , "status" , http .StatusFound , "path" , idxPath )
379
384
http .Redirect (w , r , redirectURL , http .StatusFound )
380
- logger .Debugw ("error (type nil) getting file tree for index.html and dir w/o slash, redirect" , "to" , redirectURL , "status" , http .StatusFound , "path" , idxPath )
381
385
return
382
386
}
383
387
@@ -387,12 +391,12 @@ func (i *gatewayHandler) getOrHeadHandler(w http.ResponseWriter, r *http.Request
387
391
return
388
392
}
389
393
390
- logger .Debugw ("error (type nil) getting file tree for index.html, serve the file" , "path" , idxPath )
394
+ logger .Debugw ("serving index.html file" , "path" , idxPath )
391
395
// write to request
392
396
i .serveFile (w , r , "index.html" , modtime , f )
393
397
return
394
398
case resolver.ErrNoLink :
395
- logger .Debugw ("error getting file tree, no index.html; noop" , "path" , idxPath )
399
+ logger .Debugw ("no index.html; noop" , "path" , idxPath )
396
400
default :
397
401
internalWebError (w , err )
398
402
return
@@ -403,8 +407,8 @@ func (i *gatewayHandler) getOrHeadHandler(w http.ResponseWriter, r *http.Request
403
407
// Note: this needs to occur before listingTemplate.Execute otherwise we get
404
408
// superfluous response.WriteHeader call from prometheus/client_golang
405
409
if w .Header ().Get ("Location" ) != "" {
406
- w .WriteHeader (http .StatusMovedPermanently )
407
410
logger .Debugw ("location moved permanently" , "status" , http .StatusMovedPermanently )
411
+ w .WriteHeader (http .StatusMovedPermanently )
408
412
return
409
413
}
410
414
@@ -600,8 +604,8 @@ func (i *gatewayHandler) postHandler(w http.ResponseWriter, r *http.Request) {
600
604
601
605
i .addUserHeaders (w ) // ok, _now_ write user's headers.
602
606
w .Header ().Set ("IPFS-Hash" , p .Cid ().String ())
603
- http .Redirect (w , r , p .String (), http .StatusCreated )
604
607
log .Debugw ("CID created, http redirect" , "from" , r .URL , "to" , p , "status" , http .StatusCreated )
608
+ http .Redirect (w , r , p .String (), http .StatusCreated )
605
609
}
606
610
607
611
func (i * gatewayHandler ) putHandler (w http.ResponseWriter , r * http.Request ) {
@@ -695,8 +699,8 @@ func (i *gatewayHandler) putHandler(w http.ResponseWriter, r *http.Request) {
695
699
w .Header ().Set ("IPFS-Hash" , newcid .String ())
696
700
697
701
redirectURL := gopath .Join (ipfsPathPrefix , newcid .String (), newPath )
698
- http .Redirect (w , r , redirectURL , http .StatusCreated )
699
702
log .Debugw ("CID replaced, http redirect" , "from" , r .URL , "to" , redirectURL , "status" , http .StatusCreated )
703
+ http .Redirect (w , r , redirectURL , http .StatusCreated )
700
704
}
701
705
702
706
func (i * gatewayHandler ) deleteHandler (w http.ResponseWriter , r * http.Request ) {
@@ -770,8 +774,8 @@ func (i *gatewayHandler) deleteHandler(w http.ResponseWriter, r *http.Request) {
770
774
771
775
redirectURL := gopath .Join (ipfsPathPrefix + ncid .String (), directory )
772
776
// note: StatusCreated is technically correct here as we created a new resource.
773
- http .Redirect (w , r , redirectURL , http .StatusCreated )
774
777
log .Debugw ("CID deleted, http redirect" , "from" , r .URL , "to" , redirectURL , "status" , http .StatusCreated )
778
+ http .Redirect (w , r , redirectURL , http .StatusCreated )
775
779
}
776
780
777
781
func (i * gatewayHandler ) addUserHeaders (w http.ResponseWriter ) {
0 commit comments