diff options
author | Ben B <benne@klimlive.de> | 2020-04-03 12:40:50 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-03 11:40:50 +0100 |
commit | 955244c09298d0e6c870377dad3af2ffa1f5e578 (patch) | |
tree | 746c74e6efdae1eec0f06930b07bf0a23dfc55f7 /eduserver/api | |
parent | 2c8950221ef47cf4298dbd1f6e94450e4c35a81e (diff) |
use custom http client instead of the http DefaultClient (#823)
This commit replaces the default client from the http lib with a custom one.
The previously used default client doesn't come with a timeout. This could cause
unwanted locks.
That solution chosen here creates a http client in the base component dendrite
with a constant timeout of 30 seconds. If it should be necessary to overwrite
this, we could include the timeout in the dendrite configuration.
Here it would be a good idea to extend the type "Address" by a timeout and
create an http client for each service.
Closes #820
Signed-off-by: Benedikt Bongartz <benne@klimlive.de>
Co-authored-by: Kegsay <kegan@matrix.org>
Diffstat (limited to 'eduserver/api')
-rw-r--r-- | eduserver/api/input.go | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/eduserver/api/input.go b/eduserver/api/input.go index ad3f1ed5..be2d4c56 100644 --- a/eduserver/api/input.go +++ b/eduserver/api/input.go @@ -15,6 +15,7 @@ package api import ( "context" + "errors" "net/http" commonHTTP "github.com/matrix-org/dendrite/common/http" @@ -57,11 +58,11 @@ type EDUServerInputAPI interface { const EDUServerInputTypingEventPath = "/api/eduserver/input" // NewEDUServerInputAPIHTTP creates a EDUServerInputAPI implemented by talking to a HTTP POST API. -func NewEDUServerInputAPIHTTP(eduServerURL string, httpClient *http.Client) EDUServerInputAPI { +func NewEDUServerInputAPIHTTP(eduServerURL string, httpClient *http.Client) (EDUServerInputAPI, error) { if httpClient == nil { - httpClient = http.DefaultClient + return nil, errors.New("NewTypingServerInputAPIHTTP: httpClient is <nil>") } - return &httpEDUServerInputAPI{eduServerURL, httpClient} + return &httpEDUServerInputAPI{eduServerURL, httpClient}, nil } type httpEDUServerInputAPI struct { |