func testPOST(serviceDomain string, useTLS bool) { var contentLength uint64 = 1024 * 1024 * 1024 fog.Debug("start post %dmb", contentLength/(1024*1024)) client, scheme := getClient(useTLS) url := fmt.Sprintf("%s://%s/admin", scheme, serviceDomain) bodyReader := tools.NewSizeReader(contentLength) request, err := http.NewRequest("POST", url, bodyReader) if err != nil { fog.Critical("NewRequest (POST) failed %s", err) } request.TransferEncoding = []string{"identity"} request.Header.Add("Content-Type", "text/plain") request.Header.Add("Content-Length", fmt.Sprintf("%s", contentLength)) request.ContentLength = int64(contentLength) response, err := client.Do(request) if err != nil { fog.Error("post %s", err) return } tools.ReadAndDiscard(response.Body) response.Body.Close() fog.Debug("finished post %s", response.Status) }
func (s serverImpl) handleGET(w http.ResponseWriter, req *http.Request) { fog.Debug("(%s) got request %s %s", s.Name, req.Method, req.URL) if req.Body != nil { tools.ReadAndDiscard(req.Body) req.Body.Close() } var contentLength uint64 = 1024 * 1024 * 1024 fog.Debug("response body %dmb", contentLength/(1024*1024)) bodyReader := tools.NewSizeReader(contentLength) http.ServeContent(w, req, "content.txt", time.Now(), bodyReader) }