More httputil tests for the docker header

follow-on to #15911

Signed-off-by: Doug Davis <dug@us.ibm.com>
This commit is contained in:
Doug Davis 2015-08-28 11:54:44 -07:00
parent 0ffa6f1bb6
commit 9bf309f3f8
2 changed files with 49 additions and 32 deletions

View file

@ -5,12 +5,13 @@ import (
"fmt"
"net/http"
"regexp"
"strings"
"github.com/docker/docker/pkg/jsonmessage"
)
var (
headerRegexp = regexp.MustCompile(`^(?:(.+)/(.+))\s\((.+)\).*$`)
headerRegexp = regexp.MustCompile(`^(?:(.+)/(.+?))\((.+)\).*$`)
errInvalidHeader = errors.New("Bad header, should be in format `docker/version (platform)`")
)
@ -48,8 +49,8 @@ func ParseServerHeader(hdr string) (*ServerHeader, error) {
return nil, errInvalidHeader
}
return &ServerHeader{
App: matches[1],
Ver: matches[2],
OS: matches[3],
App: strings.TrimSpace(matches[1]),
Ver: strings.TrimSpace(matches[2]),
OS: strings.TrimSpace(matches[3]),
}, nil
}