Browse Source

Fix broken build on Go 1.6

Martin Hebnes Pedersen 1 year ago
parent
commit
f838cf28f7
3 changed files with 18 additions and 1 deletions
  1. 1 1
      http.go
  2. 9 0
      http_multipart.go
  3. 8 0
      http_multipart_pre110.go

+ 1 - 1
http.go

@@ -192,7 +192,7 @@ func postOutboundMessageHandler(w http.ResponseWriter, r *http.Request) {
 		// For some unknown reason, we receive this empty unnamed file when no
 		// attachment is provided. Prior to Go 1.10, this was filtered by
 		// multipart.Reader.
-		if f.Size == 0 && f.Filename == "" {
+		if isEmptyFormFile(f) {
 			continue
 		}
 

+ 9 - 0
http_multipart.go

@@ -0,0 +1,9 @@
+// +build go1.10
+
+package main
+
+import "mime/multipart"
+
+func isEmptyFormFile(f *multipart.FileHeader) bool {
+	return f.Size == 0 && f.Filename == ""
+}

+ 8 - 0
http_multipart_pre110.go

@@ -0,0 +1,8 @@
+// +build !go1.10
+
+package main
+
+import "mime/multipart"
+
+// Prior to Go 1.10, empty form files was filtered automatically by the multipart.Parser
+func isEmptyFormFile(f *multipart.FileHeader) bool { return false }