diff --git a/cmd/pastad/pastad.go b/cmd/pastad/pastad.go index 42abf16..b590057 100644 --- a/cmd/pastad/pastad.go +++ b/cmd/pastad/pastad.go @@ -390,21 +390,22 @@ func ReceivePasta(r *http.Request) (Pasta, error) { pasta.Id = "" return pasta, err } - } - // Check if the input is coming from the POST form - inputs := r.URL.Query()["input"] - if len(inputs) > 0 && inputs[0] == "form" { - // Copy reader, as r.FromValue consumes it's contents - defer r.Body.Close() - reader = r.Body - if content := r.FormValue("content"); content != "" { - reader = io.NopCloser(strings.NewReader(content)) + } else { + // Check if the input is coming from the POST form + inputs := r.URL.Query()["input"] + if len(inputs) > 0 && inputs[0] == "form" { + // Copy reader, as r.FromValue consumes it's contents + defer r.Body.Close() + reader = r.Body + if content := r.FormValue("content"); content != "" { + reader = io.NopCloser(strings.NewReader(content)) + } else { + pasta.Id = "" // Empty pasta + return pasta, nil + } } else { - pasta.Id = "" // Empty pasta - return pasta, nil + reader = r.Body } - } else { - reader = r.Body } defer reader.Close()