Skip to content

Commit

Permalink
feat: set text/plain content-type on Micropub create response
Browse files Browse the repository at this point in the history
  • Loading branch information
jlelse committed Dec 20, 2023
1 parent 8f2ce2a commit bddf566
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions micropub/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,7 @@ func (h *handler) micropubPost(w http.ResponseWriter, r *http.Request) {
serveError(w, err)
return
}
w.Header().Set("Content-Type", "text/plain")
http.Redirect(w, r, location, http.StatusAccepted)
case ActionUpdate:
if !h.checkScope(w, r, "update") {
Expand Down
4 changes: 4 additions & 0 deletions micropub/handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,13 +226,17 @@ func TestRouterPost(t *testing.T) {
case ActionCreate:
assert.Equal(t, "https://example.org/1", w.Result().Header.Get("Location"))
assert.Equal(t, http.StatusAccepted, w.Result().StatusCode)
assert.Equal(t, "text/plain", w.Result().Header.Get("Content-Type"))
case ActionUpdate:
assert.Equal(t, request.response.URL, w.Result().Header.Get("Location"))
assert.Equal(t, http.StatusOK, w.Result().StatusCode)
assert.Equal(t, "", w.Result().Header.Get("Content-Type"))
case ActionDelete:
assert.Equal(t, http.StatusOK, w.Result().StatusCode)
assert.Equal(t, "", w.Result().Header.Get("Content-Type"))
case ActionUndelete:
assert.Equal(t, http.StatusOK, w.Result().StatusCode)
assert.Equal(t, "", w.Result().Header.Get("Content-Type"))
}
}
})
Expand Down

0 comments on commit bddf566

Please sign in to comment.