From 1cab1ecb0ece87d79b6c8689d867df8fb59a8040 Mon Sep 17 00:00:00 2001 From: Leonid Bugaev Date: Mon, 13 Oct 2014 18:54:47 +0400 Subject: [PATCH] Add EmitFile for test purpose --- test_input.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/test_input.go b/test_input.go index 54c6a3d..2ee4ef2 100644 --- a/test_input.go +++ b/test_input.go @@ -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") }