Skip to content

Commit

Permalink
refactor: odoh debug logs
Browse files Browse the repository at this point in the history
  • Loading branch information
natesales committed Jul 1, 2023
1 parent 10b9ef3 commit 9517ef0
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions transport/odoh.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,24 +109,21 @@ func ODoH(query dns.Msg, target, proxy string) (*dns.Msg, error) {
}
p.RawQuery = qry.Encode()

log.Debugf("POST %s %+v", p, odnsMessage)
req, err = http.NewRequest(http.MethodPost, p.String(), bytes.NewBuffer(odnsMessage.Marshal()))
if err != nil {
return nil, fmt.Errorf("create new request: %s", err)
}

req.Header.Set("Content-Type", ODoHContentType)
req.Header.Set("Accept", ODoHContentType)

resp, err = client.Do(req)
if err != nil {
return nil, fmt.Errorf("do request: %s", err)
}

contentType := resp.Header.Get("Content-Type")
if contentType != ODoHContentType {
return nil, fmt.Errorf("target %s responded with an invalid Content-Type header %s, expected %s",
target, contentType, ODoHContentType,
)
return nil, fmt.Errorf("%s responded with an invalid Content-Type header %s, expected %s", req.URL, contentType, ODoHContentType)
}

bodyBytes, err = io.ReadAll(resp.Body)
Expand Down

0 comments on commit 9517ef0

Please sign in to comment.