2014-08-07 14:43:06 +00:00
|
|
|
package registry
|
|
|
|
|
|
|
|
import (
|
|
|
|
"runtime"
|
|
|
|
|
2015-02-04 21:22:38 +00:00
|
|
|
"github.com/docker/docker/autogen/dockerversion"
|
2014-08-07 14:43:06 +00:00
|
|
|
"github.com/docker/docker/pkg/parsers/kernel"
|
2015-03-29 13:51:08 +00:00
|
|
|
"github.com/docker/docker/pkg/requestdecorator"
|
2014-08-07 14:43:06 +00:00
|
|
|
)
|
|
|
|
|
2015-03-29 13:51:08 +00:00
|
|
|
func HTTPRequestFactory(metaHeaders map[string][]string) *requestdecorator.RequestFactory {
|
2014-08-07 14:43:06 +00:00
|
|
|
// FIXME: this replicates the 'info' job.
|
2015-03-29 13:51:08 +00:00
|
|
|
httpVersion := make([]requestdecorator.UAVersionInfo, 0, 4)
|
|
|
|
httpVersion = append(httpVersion, requestdecorator.NewUAVersionInfo("docker", dockerversion.VERSION))
|
|
|
|
httpVersion = append(httpVersion, requestdecorator.NewUAVersionInfo("go", runtime.Version()))
|
|
|
|
httpVersion = append(httpVersion, requestdecorator.NewUAVersionInfo("git-commit", dockerversion.GITCOMMIT))
|
2014-08-07 14:43:06 +00:00
|
|
|
if kernelVersion, err := kernel.GetKernelVersion(); err == nil {
|
2015-03-29 13:51:08 +00:00
|
|
|
httpVersion = append(httpVersion, requestdecorator.NewUAVersionInfo("kernel", kernelVersion.String()))
|
2014-08-07 14:43:06 +00:00
|
|
|
}
|
2015-03-29 13:51:08 +00:00
|
|
|
httpVersion = append(httpVersion, requestdecorator.NewUAVersionInfo("os", runtime.GOOS))
|
|
|
|
httpVersion = append(httpVersion, requestdecorator.NewUAVersionInfo("arch", runtime.GOARCH))
|
|
|
|
uad := &requestdecorator.UserAgentDecorator{
|
|
|
|
Versions: httpVersion,
|
|
|
|
}
|
|
|
|
mhd := &requestdecorator.MetaHeadersDecorator{
|
2014-08-07 14:43:06 +00:00
|
|
|
Headers: metaHeaders,
|
|
|
|
}
|
2015-03-29 13:51:08 +00:00
|
|
|
factory := requestdecorator.NewRequestFactory(uad, mhd)
|
2014-08-07 14:43:06 +00:00
|
|
|
return factory
|
|
|
|
}
|