MM-10417 Improve HTTPService for use in image proxy (#9966)
* Replaced httpservice with proper http.Client * Added HTTPService.MakeTransport * Expose timeouts used by HTTPServiceImpl * Add additional documentation to HTTPService * Remove MockedHTTPService * Fix missing license
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
f42c00ee53
Коммит
749a3e7538
21
services/httpservice/transport.go
Обычный файл
21
services/httpservice/transport.go
Обычный файл
@@ -0,0 +1,21 @@
|
||||
// Copyright (c) 2017-present Mattermost, Inc. All Rights Reserved.
|
||||
// See License.txt for license information.
|
||||
|
||||
package httpservice
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
)
|
||||
|
||||
// MattermostTransport is an implementation of http.RoundTripper that ensures each request contains a custom user agent
|
||||
// string to indicate that the request is coming from a Mattermost instance.
|
||||
type MattermostTransport struct {
|
||||
// Transport is the underlying http.RoundTripper that is actually used to make the request
|
||||
Transport http.RoundTripper
|
||||
}
|
||||
|
||||
func (t *MattermostTransport) RoundTrip(req *http.Request) (*http.Response, error) {
|
||||
req.Header.Set("User-Agent", defaultUserAgent)
|
||||
|
||||
return t.Transport.RoundTrip(req)
|
||||
}
|
||||
Ссылка в новой задаче
Block a user