httpreplay: remove error on empty content-type
We failed if a request had no Content-Type header but did have a body.
It's unclear why.
Now we succeed.
@@ -16,7 +16,6 @@ package proxy
import (
"bytes"
- "errors"
"io"
"io/ioutil"
"mime"
@@ -157,11 +156,8 @@ func (c *Converter) convertRequest(req *http.Request) (*Request, error) {
// parts if necessary. It returns the media type and the body parts.
func parseRequestBody(contentType string, body []byte) (string, [][]byte, error) {
if contentType == "" {
- // No content-type header. There should not be a body.
- if len(body) != 0 {
- return "", nil, errors.New("no Content-Type, but body")
- }
- return "", nil, nil
+ // No content-type header. Treat the body as a single part.
+ return "", [][]byte{body}, nil
}
mediaType, params, err := mime.ParseMediaType(contentType)
if err != nil {
