Add ETag support to WHIP server.
This commit is contained in:
+14
-2
@@ -243,6 +243,8 @@ func whipEndpointHandler(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
c.SetETag("\"" + newId() + "\"")
|
||||
|
||||
answer, err := c.NewConnection(r.Context(), body)
|
||||
if err != nil {
|
||||
group.DelClient(c)
|
||||
@@ -253,9 +255,10 @@ func whipEndpointHandler(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
w.Header().Set("Location", path.Join(r.URL.Path, obfuscated))
|
||||
w.Header().Set("Access-Control-Expose-Headers",
|
||||
"Location, Content-Type, Link")
|
||||
"Location, Content-Type, Link, ETag")
|
||||
whipICEServers(w)
|
||||
w.Header().Set("Content-Type", "application/sdp")
|
||||
w.Header().Set("ETag", c.ETag())
|
||||
w.WriteHeader(http.StatusCreated)
|
||||
w.Write(answer)
|
||||
|
||||
@@ -322,12 +325,16 @@ func whipResourceHandler(w http.ResponseWriter, r *http.Request) {
|
||||
"OPTIONS, DELETE, PATCH",
|
||||
)
|
||||
w.Header().Set("Access-Control-Allow-Headers",
|
||||
"Authorization, Content-Type",
|
||||
"Authorization, Content-Type, If-Match, If-None-Match",
|
||||
)
|
||||
return
|
||||
}
|
||||
|
||||
if r.Method == "DELETE" {
|
||||
done := checkPreconditions(w, r, c.ETag())
|
||||
if done {
|
||||
return
|
||||
}
|
||||
c.Close()
|
||||
return
|
||||
}
|
||||
@@ -338,6 +345,11 @@ func whipResourceHandler(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
}
|
||||
|
||||
done := checkPreconditions(w, r, c.ETag())
|
||||
if done {
|
||||
return
|
||||
}
|
||||
|
||||
ctype := r.Header.Get("content-type")
|
||||
if !strings.EqualFold(ctype, "application/trickle-ice-sdpfrag") {
|
||||
w.Header().Set("Accept", "application/trickle-ice-sdpfrag")
|
||||
|
||||
Reference in New Issue
Block a user