WithBasicAuth sets the request's Authorization header to use HTTP Basic Authentication with the provided username and password. With HTTP Basic Authentication the provided username and password are not encrypted. Example: req := NewRequestC(config, "PUT", "http://example.com/path") req.WithBasi
(username, password string)
| 1644 | // req := NewRequestC(config, "PUT", "http://example.com/path") |
| 1645 | // req.WithBasicAuth("john", "secret") |
| 1646 | func (r *Request) WithBasicAuth(username, password string) *Request { |
| 1647 | opChain := r.chain.enter("WithBasicAuth()") |
| 1648 | defer opChain.leave() |
| 1649 | |
| 1650 | r.mu.Lock() |
| 1651 | defer r.mu.Unlock() |
| 1652 | |
| 1653 | if opChain.failed() { |
| 1654 | return r |
| 1655 | } |
| 1656 | |
| 1657 | if !r.checkOrder(opChain, "WithBasicAuth()") { |
| 1658 | return r |
| 1659 | } |
| 1660 | |
| 1661 | r.httpReq.SetBasicAuth(username, password) |
| 1662 | |
| 1663 | return r |
| 1664 | } |
| 1665 | |
| 1666 | // WithHost sets request host to given string. |
| 1667 | // |