Skip to content

Commit

Permalink
WIP: Dump HTTP operations
Browse files Browse the repository at this point in the history
Signed-off-by: Miloslav Trmač <[email protected]>
  • Loading branch information
mtrmac committed Mar 2, 2017
1 parent 1fc5ae4 commit a49b9fb
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
9 changes: 9 additions & 0 deletions docker/docker_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"io/ioutil"
"net"
"net/http"
"net/http/httputil"
"os"
"path/filepath"
"strings"
Expand Down Expand Up @@ -248,10 +249,14 @@ func (c *dockerClient) makeRequestToResolvedURL(method, url string, headers map[
}
}
logrus.Debugf("%s %s", method, url)
dro, _ := httputil.DumpRequestOut(req, false)
logrus.Errorf("===REQ===\n%s\n===REQ===\n", dro)
res, err := c.client.Do(req)
if err != nil {
return nil, err
}
dr, _ := httputil.DumpResponse(res, false)
logrus.Errorf("===RES===\n%s\n===RES===\n", dr)
return res, nil
}

Expand Down Expand Up @@ -313,10 +318,14 @@ func (c *dockerClient) getBearerToken(realm, service, scope string) (*bearerToke
// TODO(runcom): insecure for now to contact the external token service
tr.TLSClientConfig = &tls.Config{InsecureSkipVerify: true}
client := &http.Client{Transport: tr}
dro, _ := httputil.DumpRequestOut(authReq, false)
logrus.Errorf("===REQ===\n%s\n===REQ===\n", dro)
res, err := client.Do(authReq)
if err != nil {
return nil, err
}
dr, _ := httputil.DumpResponse(res, false)
logrus.Errorf("===RES===\n%s\n===RES===\n", dr)
defer res.Body.Close()
switch res.StatusCode {
case http.StatusUnauthorized:
Expand Down
9 changes: 6 additions & 3 deletions openshift/openshift.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"io"
"io/ioutil"
"net/http"
"net/http/httputil"
"net/url"
"strings"

Expand Down Expand Up @@ -95,18 +96,20 @@ func (c *openshiftClient) doRequest(method, path string, requestBody []byte) ([]
}

logrus.Debugf("%s %s", method, url)
dro, _ := httputil.DumpRequestOut(req, false)
logrus.Errorf("===REQ===\n%s\n===REQ===\n", dro)
res, err := c.httpClient.Do(req)
if err != nil {
return nil, err
}
dr, _ := httputil.DumpResponse(res, false)
logrus.Errorf("===RES===\n%s\n===RES===\n", dr)
defer res.Body.Close()
body, err := ioutil.ReadAll(res.Body)
if err != nil {
return nil, err
}
logrus.Debugf("Got body: %s", body)
// FIXME: Just throwing this useful information away only to try to guess later...
logrus.Debugf("Got content-type: %s", res.Header.Get("Content-Type"))
// FIXME: Just throwing Content-Type away only to try to guess later...

var status status
statusValid := false
Expand Down

0 comments on commit a49b9fb

Please sign in to comment.