diff --git a/net/ghttp/ghttp_server_handler.go b/net/ghttp/ghttp_server_handler.go
index 184ef1395..ae447e064 100644
--- a/net/ghttp/ghttp_server_handler.go
+++ b/net/ghttp/ghttp_server_handler.go
@@ -12,6 +12,8 @@ import (
"sort"
"strings"
+ "github.com/gogf/gf/text/gstr"
+
"github.com/gogf/gf/errors/gerror"
"github.com/gogf/gf/os/gres"
@@ -276,7 +278,11 @@ func (s *Server) listDir(r *Request, f http.File) {
r.Response.Header().Set("Content-Type", "text/html; charset=utf-8")
}
r.Response.Write(``)
- r.Response.Write(`
`)
+ r.Response.Write(``)
+ r.Response.Write(``)
+ r.Response.Write(``)
r.Response.Write(``)
r.Response.Writef(`Index of %s
`, r.URL.Path)
r.Response.Writef(`
`)
@@ -288,6 +294,7 @@ func (s *Server) listDir(r *Request, f http.File) {
}
name := ""
size := ""
+ prefix := gstr.TrimRight(r.URL.Path, "/")
for _, file := range files {
name = file.Name()
size = gfile.FormatSize(file.Size())
@@ -296,9 +303,9 @@ func (s *Server) listDir(r *Request, f http.File) {
size = "-"
}
r.Response.Write(``)
- r.Response.Writef(`| %s | `, r.URL.Path, name, ghtml.SpecialChars(name))
+ r.Response.Writef(`%s | `, prefix, name, ghtml.SpecialChars(name))
r.Response.Writef(`%s | `, gtime.New(file.ModTime()).ISO8601())
- r.Response.Writef(`%s | `, size)
+ r.Response.Writef(`%s | `, size)
r.Response.Write(`
`)
}
r.Response.Write(``)
diff --git a/net/ghttp/ghttp_unit_static_test.go b/net/ghttp/ghttp_unit_static_test.go
index 991bee1a3..ea33b943b 100644
--- a/net/ghttp/ghttp_unit_static_test.go
+++ b/net/ghttp/ghttp_unit_static_test.go
@@ -12,6 +12,8 @@ import (
"testing"
"time"
+ "github.com/gogf/gf/text/gstr"
+
"github.com/gogf/gf/frame/g"
"github.com/gogf/gf/net/ghttp"
"github.com/gogf/gf/os/gfile"
@@ -96,6 +98,7 @@ func Test_Static_IndexFolder(t *testing.T) {
client.SetPrefix(fmt.Sprintf("http://127.0.0.1:%d", p))
gtest.AssertNE(client.GetContent("/"), "Forbidden")
+ gtest.AssertNE(gstr.Pos(client.GetContent("/"), `