Skip to content
This repository has been archived by the owner on Nov 24, 2022. It is now read-only.

Commit

Permalink
Fixes #4
Browse files Browse the repository at this point in the history
Disabled HTTP/2 because Runtastic server don't handle it properly.
  • Loading branch information
Metalnem committed May 31, 2017
1 parent ca86f19 commit ddcd6fa
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions api/api.go
Expand Up @@ -5,6 +5,7 @@ import (
"bytes"
"context"
"crypto/sha1"
"crypto/tls"
"encoding/base64"
"encoding/binary"
"encoding/hex"
Expand Down Expand Up @@ -39,6 +40,12 @@ const (
var (
baseURL = "https://appws.runtastic.com"

client = http.Client{
Transport: &http.Transport{
TLSNextProto: make(map[string]func(authority string, c *tls.Conn) http.RoundTripper),
},
}

errAuthenticationFailed = errors.New("Invalid email address or password")
errInvalidLoginResponse = errors.New("Invalid login response from server")
errInvalidActivitiesResponse = errors.New("Invalid activity list response from server")
Expand Down Expand Up @@ -227,8 +234,6 @@ func Login(ctx context.Context, email, password string) (*Session, error) {
}

setHeaders(req.Header)

client := new(http.Client)
resp, err := client.Do(req.WithContext(ctx))

if err != nil {
Expand Down Expand Up @@ -335,8 +340,6 @@ func (session *Session) GetMetadata(ctx context.Context) ([]Metadata, error) {

setHeaders(req.Header)
req.AddCookie(&http.Cookie{Name: sessionCookie, Value: session.cookie})

client := new(http.Client)
resp, err := client.Do(req.WithContext(newCtx))

if err != nil {
Expand Down Expand Up @@ -589,8 +592,6 @@ func (session *Session) GetActivity(ctx context.Context, id ActivityID) (*Activi

setHeaders(req.Header)
req.AddCookie(&http.Cookie{Name: sessionCookie, Value: session.cookie})

client := new(http.Client)
resp, err := client.Do(req.WithContext(ctx))

setHeaders(req.Header)
Expand Down

0 comments on commit ddcd6fa

Please sign in to comment.