Skip to content

Commit

Permalink
Rename some HTTP identifiers to Http
Browse files Browse the repository at this point in the history
I believe the Go convention on this is bad, and this names them inline with the style used elsewhere in anacrolix/torrent with Ip for example.

Unfortunately it's pretty widespread, so I've only changed the recent additions.
  • Loading branch information
anacrolix committed Nov 28, 2022
1 parent 916af6e commit 3d49eec
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,9 @@ type ClientConfig struct {
LookupTrackerIp func(*url.URL) ([]net.IP, error)
// HTTPUserAgent changes default UserAgent for HTTP requests
HTTPUserAgent string
// HTTPRequestDirector modifies the request before it's sent.
// HttpRequestDirector modifies the request before it's sent.
// Useful for adding authentication headers, for example
HTTPRequestDirector func(*http.Request) error
HttpRequestDirector func(*http.Request) error
// Updated occasionally to when there's been some changes to client
// behaviour in case other clients are assuming anything of us. See also
// `bep20`.
Expand Down
6 changes: 3 additions & 3 deletions tracker/http/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ type AnnounceOpt struct {
HostHeader string
ClientIp4 net.IP
ClientIp6 net.IP
HTTPRequestDirector func(*http.Request) error
HttpRequestDirector func(*http.Request) error
}

type AnnounceRequest = udp.AnnounceRequest
Expand All @@ -97,8 +97,8 @@ func (cl Client) Announce(ctx context.Context, ar AnnounceRequest, opt AnnounceO
req.Header.Set("User-Agent", userAgent)
}

if opt.HTTPRequestDirector != nil {
err = opt.HTTPRequestDirector(req)
if opt.HttpRequestDirector != nil {
err = opt.HttpRequestDirector(req)
if err != nil {
err = fmt.Errorf("error modifying HTTP request: %s", err)
return
Expand Down
8 changes: 4 additions & 4 deletions tracker/tracker.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ type Announce struct {
TrackerUrl string
Request AnnounceRequest
HostHeader string
HTTPProxy func(*http.Request) (*url.URL, error)
HTTPRequestDirector func(*http.Request) error
HttpProxy func(*http.Request) (*url.URL, error)
HttpRequestDirector func(*http.Request) error
DialContext func(ctx context.Context, network, addr string) (net.Conn, error)
ListenPacket func(network, addr string) (net.PacketConn, error)
ServerName string
Expand All @@ -59,7 +59,7 @@ const DefaultTrackerAnnounceTimeout = 15 * time.Second
func (me Announce) Do() (res AnnounceResponse, err error) {
cl, err := NewClient(me.TrackerUrl, NewClientOpts{
Http: trHttp.NewClientOpts{
Proxy: me.HTTPProxy,
Proxy: me.HttpProxy,
DialContext: me.DialContext,
ServerName: me.ServerName,
},
Expand All @@ -84,6 +84,6 @@ func (me Announce) Do() (res AnnounceResponse, err error) {
HostHeader: me.HostHeader,
ClientIp4: me.ClientIp4.IP,
ClientIp6: me.ClientIp6.IP,
HTTPRequestDirector: me.HTTPRequestDirector,
HttpRequestDirector: me.HttpRequestDirector,
})
}
4 changes: 2 additions & 2 deletions tracker_scraper.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,8 @@ func (me *trackerScraper) announce(ctx context.Context, event tracker.AnnounceEv
me.t.logger.WithDefaultLevel(log.Debug).Printf("announcing to %q: %#v", me.u.String(), req)
res, err := tracker.Announce{
Context: ctx,
HTTPProxy: me.t.cl.config.HTTPProxy,
HTTPRequestDirector: me.t.cl.config.HTTPRequestDirector,
HttpProxy: me.t.cl.config.HTTPProxy,
HttpRequestDirector: me.t.cl.config.HttpRequestDirector,
DialContext: me.t.cl.config.TrackerDialContext,
ListenPacket: me.t.cl.config.TrackerListenPacket,
UserAgent: me.t.cl.config.HTTPUserAgent,
Expand Down

0 comments on commit 3d49eec

Please sign in to comment.