modified internal/server/feeds_handler.go +13 -1
| @@ -4,6 +4,7 @@ import ( |
| 4 | 4 | "context" |
| 5 | 5 | "errors" |
| 6 | 6 | "fmt" |
| 7 | + "io" |
| 7 | 8 | "net/http" |
| 8 | 9 | "net/url" |
| 9 | 10 | "time" |
| @@ -281,7 +282,18 @@ func (s *Server) handleEditFeed(w http.ResponseWriter, r *http.Request) { |
| 281 | 282 | |
| 282 | 283 | func (s *Server) handleRemoveFeed(w http.ResponseWriter, r *http.Request) { |
| 283 | 284 | user := currentUser(r) |
| 284 | | - feedURL := r.FormValue("url") |
| 285 | + |
| 286 | + // FormValue only parses the body for POST/PUT/PATCH; for DELETE we read it manually. |
| 287 | + feedURL := r.URL.Query().Get("url") |
| 288 | + if feedURL == "" { |
| 289 | + body, err := io.ReadAll(http.MaxBytesReader(w, r.Body, 1<<20)) |
| 290 | + if err == nil { |
| 291 | + vals, parseErr := url.ParseQuery(string(body)) |
| 292 | + if parseErr == nil { |
| 293 | + feedURL = vals.Get("url") |
| 294 | + } |
| 295 | + } |
| 296 | + } |
| 285 | 297 | |
| 286 | 298 | if feedURL == "" { |
| 287 | 299 | writeAPIError(w, http.StatusBadRequest, "url required") |
| @@ -4,6 +4,7 @@ import ( |
| 4 | "context" | 4 | "context" |
| 5 | "errors" | 5 | "errors" |
| 6 | "fmt" | 6 | "fmt" |
| | 7 | + "io" |
| 7 | "net/http" | 8 | "net/http" |
| 8 | "net/url" | 9 | "net/url" |
| 9 | "time" | 10 | "time" |
| @@ -281,7 +282,18 @@ func (s *Server) handleEditFeed(w http.ResponseWriter, r *http.Request) { |
| 281 | | 282 | |
| 282 | func (s *Server) handleRemoveFeed(w http.ResponseWriter, r *http.Request) { | 283 | func (s *Server) handleRemoveFeed(w http.ResponseWriter, r *http.Request) { |
| 283 | user := currentUser(r) | 284 | user := currentUser(r) |
| 284 | - feedURL := r.FormValue("url") | 285 | + |
| | 286 | + // FormValue only parses the body for POST/PUT/PATCH; for DELETE we read it manually. |
| | 287 | + feedURL := r.URL.Query().Get("url") |
| | 288 | + if feedURL == "" { |
| | 289 | + body, err := io.ReadAll(http.MaxBytesReader(w, r.Body, 1<<20)) |
| | 290 | + if err == nil { |
| | 291 | + vals, parseErr := url.ParseQuery(string(body)) |
| | 292 | + if parseErr == nil { |
| | 293 | + feedURL = vals.Get("url") |
| | 294 | + } |
| | 295 | + } |
| | 296 | + } |
| 285 | | 297 | |
| 286 | if feedURL == "" { | 298 | if feedURL == "" { |
| 287 | writeAPIError(w, http.StatusBadRequest, "url required") | 299 | writeAPIError(w, http.StatusBadRequest, "url required") |