У меня есть код клиент-сервер для http2, я хочу отправить файл с клиента на сервер. Но я застрял в том, как это сделать. Означает, как разбить мой файл на небольшие кусочки и отправить его через это соединение.
Любая помощь и ссылка будут оценены.
Спасибо
//http2 client
package main
import (
"fmt"
"io/ioutil"
"log"
"net/http"
"golang.org/x/net/http2"
)
func main() {
client := http.Client{
// InsecureTLSDial is temporary and will likely be
// replaced by a different API later.
Transport: &http2.Transport{InsecureTLSDial: true},
}
// Perform the request
resp, err := client.Post("https://localhost:9191/hello/sayHello", "text/plain", bytes.NewBufferString("Hello Go!"))
if err != nil {
log.Fatalf("Failed get: %s", err)
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
log.Fatalf("Failed reading response body: %s", err)
}
fmt.Printf("Got response %d: %s %s", resp.StatusCode, resp.Proto, string(body))
}