Reads & parses the request body, handling either JSON or multipart.
()
| 1397 | |
| 1398 | // Reads & parses the request body, handling either JSON or multipart. |
| 1399 | func (h *handler) readDocument() (db.Body, error) { |
| 1400 | contentType, attrs, _ := mime.ParseMediaType(h.rq.Header.Get("Content-Type")) |
| 1401 | switch contentType { |
| 1402 | case "", "application/json": |
| 1403 | return h.readJSON() |
| 1404 | case "multipart/related": |
| 1405 | reader := multipart.NewReader(h.requestBody, attrs["boundary"]) |
| 1406 | return ReadMultipartDocument(reader) |
| 1407 | default: |
| 1408 | return nil, base.HTTPErrorf(http.StatusUnsupportedMediaType, "Invalid content type %s", contentType) |
| 1409 | } |
| 1410 | } |
| 1411 | |
| 1412 | func (h *handler) requestAccepts(mimetype string) bool { |
| 1413 | accept := h.rq.Header.Get("Accept") |
no test coverage detected