mirror of
https://github.com/aler9/rtsp-simple-server
synced 2025-10-12 19:10:19 +08:00
hls: add Server header
This commit is contained in:
@@ -329,10 +329,10 @@ func (a *api) mwLog(ctx *gin.Context) {
|
|||||||
blw := &logWriter{ResponseWriter: ctx.Writer}
|
blw := &logWriter{ResponseWriter: ctx.Writer}
|
||||||
ctx.Writer = blw
|
ctx.Writer = blw
|
||||||
|
|
||||||
ctx.Next()
|
|
||||||
|
|
||||||
ctx.Writer.Header().Set("Server", "rtsp-simple-server")
|
ctx.Writer.Header().Set("Server", "rtsp-simple-server")
|
||||||
|
|
||||||
|
ctx.Next()
|
||||||
|
|
||||||
var buf bytes.Buffer
|
var buf bytes.Buffer
|
||||||
fmt.Fprintf(&buf, "%s %d %s\n", ctx.Request.Proto, ctx.Writer.Status(), http.StatusText(ctx.Writer.Status()))
|
fmt.Fprintf(&buf, "%s %d %s\n", ctx.Request.Proto, ctx.Writer.Status(), http.StatusText(ctx.Writer.Status()))
|
||||||
ctx.Writer.Header().Write(&buf)
|
ctx.Writer.Header().Write(&buf)
|
||||||
|
@@ -142,15 +142,16 @@ func (s *hlsServer) onRequest(ctx *gin.Context) {
|
|||||||
// remove leading prefix
|
// remove leading prefix
|
||||||
pa := ctx.Request.URL.Path[1:]
|
pa := ctx.Request.URL.Path[1:]
|
||||||
|
|
||||||
ctx.Writer.Header().Add("Access-Control-Allow-Origin", s.hlsAllowOrigin)
|
ctx.Writer.Header().Set("Server", "rtsp-simple-server")
|
||||||
ctx.Writer.Header().Add("Access-Control-Allow-Credentials", "true")
|
ctx.Writer.Header().Set("Access-Control-Allow-Origin", s.hlsAllowOrigin)
|
||||||
|
ctx.Writer.Header().Set("Access-Control-Allow-Credentials", "true")
|
||||||
|
|
||||||
switch ctx.Request.Method {
|
switch ctx.Request.Method {
|
||||||
case http.MethodGet:
|
case http.MethodGet:
|
||||||
|
|
||||||
case http.MethodOptions:
|
case http.MethodOptions:
|
||||||
ctx.Writer.Header().Add("Access-Control-Allow-Methods", "GET, OPTIONS")
|
ctx.Writer.Header().Set("Access-Control-Allow-Methods", "GET, OPTIONS")
|
||||||
ctx.Writer.Header().Add("Access-Control-Allow-Headers", ctx.Request.Header.Get("Access-Control-Request-Headers"))
|
ctx.Writer.Header().Set("Access-Control-Allow-Headers", ctx.Request.Header.Get("Access-Control-Request-Headers"))
|
||||||
ctx.Writer.WriteHeader(http.StatusOK)
|
ctx.Writer.WriteHeader(http.StatusOK)
|
||||||
return
|
return
|
||||||
|
|
||||||
@@ -173,7 +174,7 @@ func (s *hlsServer) onRequest(ctx *gin.Context) {
|
|||||||
}()
|
}()
|
||||||
|
|
||||||
if fname == "" && !strings.HasSuffix(dir, "/") {
|
if fname == "" && !strings.HasSuffix(dir, "/") {
|
||||||
ctx.Writer.Header().Add("Location", "/"+dir+"/")
|
ctx.Writer.Header().Set("Location", "/"+dir+"/")
|
||||||
ctx.Writer.WriteHeader(http.StatusMovedPermanently)
|
ctx.Writer.WriteHeader(http.StatusMovedPermanently)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user