2014-08-07 16:43:06 +02:00
|
|
|
package registry
|
|
|
|
|
|
|
|
import (
|
|
|
|
"runtime"
|
|
|
|
|
2015-02-04 22:22:38 +01:00
|
|
|
"github.com/docker/docker/autogen/dockerversion"
|
2014-08-07 16:43:06 +02:00
|
|
|
"github.com/docker/docker/pkg/parsers/kernel"
|
2015-03-29 15:51:08 +02:00
|
|
|
"github.com/docker/docker/pkg/requestdecorator"
|
2014-08-07 16:43:06 +02:00
|
|
|
)
|
|
|
|
|
2015-03-29 15:51:08 +02:00
|
|
|
func HTTPRequestFactory(metaHeaders map[string][]string) *requestdecorator.RequestFactory {
|
2014-08-07 16:43:06 +02:00
|
|
|
// FIXME: this replicates the 'info' job.
|
2015-03-29 15:51:08 +02: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 16:43:06 +02:00
|
|
|
if kernelVersion, err := kernel.GetKernelVersion(); err == nil {
|
2015-03-29 15:51:08 +02:00
|
|
|
httpVersion = append(httpVersion, requestdecorator.NewUAVersionInfo("kernel", kernelVersion.String()))
|
2014-08-07 16:43:06 +02:00
|
|
|
}
|
2015-03-29 15:51:08 +02: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 16:43:06 +02:00
|
|
|
Headers: metaHeaders,
|
|
|
|
}
|
2015-03-29 15:51:08 +02:00
|
|
|
factory := requestdecorator.NewRequestFactory(uad, mhd)
|
2014-08-07 16:43:06 +02:00
|
|
|
return factory
|
|
|
|
}
|