Add EmitFile for test purpose

This commit is contained in:
Leonid Bugaev
2014-10-13 18:54:47 +04:00
parent 983bc728fa
commit 1cab1ecb0e
+15
View File
@@ -1,5 +1,10 @@
package main
import (
"encoding/base64"
"crypto/rand"
)
type TestInput struct {
data chan []byte
}
@@ -26,6 +31,16 @@ func (i *TestInput) EmitPOST() {
i.data <- []byte("POST /pub/WWW/ HTTP/1.1\nHost: www.w3.org\r\n\r\na=1&b=2\r\n\r\n")
}
func (i *TestInput) EmitFile() {
size := 1024*1024 // 1 MB
rb := make([]byte,size)
rand.Read(rb)
rs := base64.URLEncoding.EncodeToString(rb)
i.data <- []byte("POST /pub/WWW/ HTTP/1.1\nHost: www.w3.org\r\n\r\n------WebKitFormBoundaryePkpFF7tjBAqx29L\nContent-Disposition: form-data; name=\"uploadedfile\"; filename=\"hello.o\"\nContent-Type: application/x-object\n" + rs + "\r\n\r\n")
}
func (i *TestInput) EmitOPTIONS() {
i.data <- []byte("OPTIONS / HTTP/1.1\nHost: www.w3.org\r\n\r\n")
}