Parcourir la source

http2/h2i: add settings flag

Add a settings flag for users to send an initial settings frame
immediatly after connection to the server. By default an empty settings
frame is sent unless otherwise specified by the user.

Change-Id: Ic3b5ce638b6c8371557b6489fa7539050fcb630f
Reviewed-on: https://go-review.googlesource.com/16530
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Blake Mizerany il y a 10 ans
Parent
commit
c764672d0e
1 fichiers modifiés avec 13 ajouts et 0 suppressions
  1. 13 0
      http2/h2i/h2i.go

+ 13 - 0
http2/h2i/h2i.go

@@ -42,6 +42,7 @@ import (
 var (
 var (
 	flagNextProto = flag.String("nextproto", "h2,h2-14", "Comma-separated list of NPN/ALPN protocol names to negotiate.")
 	flagNextProto = flag.String("nextproto", "h2,h2-14", "Comma-separated list of NPN/ALPN protocol names to negotiate.")
 	flagInsecure  = flag.Bool("insecure", false, "Whether to skip TLS cert validation")
 	flagInsecure  = flag.Bool("insecure", false, "Whether to skip TLS cert validation")
+	flagSettings  = flag.String("settings", "empty", "comma-separated list of KEY=value settings for the initial SETTINGS frame. The magic value 'empty' sends an empty initial settings frame, and the magic value 'omit' causes no initial settings frame to be sent.")
 )
 )
 
 
 type command struct {
 type command struct {
@@ -239,6 +240,18 @@ func (app *h2i) logf(format string, args ...interface{}) {
 }
 }
 
 
 func (app *h2i) readConsole() error {
 func (app *h2i) readConsole() error {
+	if s := *flagSettings; s != "omit" {
+		var args []string
+		if s != "empty" {
+			args = strings.Split(s, ",")
+		}
+		_, c, ok := lookupCommand("settings")
+		if !ok {
+			panic("settings command not found")
+		}
+		c.run(app, args)
+	}
+
 	for {
 	for {
 		line, err := app.term.ReadLine()
 		line, err := app.term.ReadLine()
 		if err == io.EOF {
 		if err == io.EOF {