55 "errors"
66 "fmt"
77 "io"
8- gohttp "net/http"
8+ "net/http"
99 "net/url"
10+ "time"
1011
1112 "github.com/storacha/go-libstoracha/capabilities/assert"
1213 "github.com/storacha/go-libstoracha/capabilities/claim"
@@ -23,7 +24,7 @@ import (
2324 udm "github.com/storacha/go-ucanto/core/result/ok/datamodel"
2425 "github.com/storacha/go-ucanto/principal"
2526 hcmsg "github.com/storacha/go-ucanto/transport/headercar/message"
26- "github.com/storacha/go-ucanto/transport/http"
27+ ucan_http "github.com/storacha/go-ucanto/transport/http"
2728 "github.com/storacha/go-ucanto/ucan"
2829 "github.com/storacha/indexing-service/pkg/service/queryresult"
2930 "github.com/storacha/indexing-service/pkg/types"
@@ -38,7 +39,7 @@ type ErrFailedResponse struct {
3839 Body string
3940}
4041
41- func errFromResponse (res * gohttp .Response ) ErrFailedResponse {
42+ func errFromResponse (res * http .Response ) ErrFailedResponse {
4243 err := ErrFailedResponse {StatusCode : res .StatusCode }
4344
4445 message , merr := io .ReadAll (res .Body )
@@ -51,14 +52,14 @@ func errFromResponse(res *gohttp.Response) ErrFailedResponse {
5152}
5253
5354func (e ErrFailedResponse ) Error () string {
54- return fmt .Sprintf ("http request failed, status: %d %s, message: %s" , e .StatusCode , gohttp .StatusText (e .StatusCode ), e .Body )
55+ return fmt .Sprintf ("http request failed, status: %d %s, message: %s" , e .StatusCode , http .StatusText (e .StatusCode ), e .Body )
5556}
5657
5758type Client struct {
5859 servicePrincipal ucan.Principal
5960 serviceURL url.URL
6061 connection client.Connection
61- httpClient * gohttp .Client
62+ httpClient * http .Client
6263}
6364
6465func (c * Client ) execute (ctx context.Context , inv invocation.Invocation ) error {
@@ -133,7 +134,7 @@ func (c *Client) QueryClaims(ctx context.Context, query types.Query) (types.Quer
133134 q .Add ("spaces" , space .String ())
134135 }
135136 url .RawQuery = q .Encode ()
136- req , err := gohttp .NewRequestWithContext (ctx , gohttp .MethodGet , url .String (), nil )
137+ req , err := http .NewRequestWithContext (ctx , http .MethodGet , url .String (), nil )
137138 if err != nil {
138139 return nil , fmt .Errorf ("creating request: %w" , err )
139140 }
@@ -167,7 +168,7 @@ type Option func(*Client)
167168
168169// WithHTTPClient configures the HTTP client to use for making query requests
169170// and invocations.
170- func WithHTTPClient (httpClient * gohttp .Client ) Option {
171+ func WithHTTPClient (httpClient * http .Client ) Option {
171172 return func (c * Client ) {
172173 c .httpClient = httpClient
173174 }
@@ -177,12 +178,12 @@ func New(servicePrincipal ucan.Principal, serviceURL url.URL, options ...Option)
177178 c := Client {
178179 servicePrincipal : servicePrincipal ,
179180 serviceURL : serviceURL ,
180- httpClient : gohttp . DefaultClient ,
181+ httpClient : & http. Client { Timeout : 30 * time . Second } ,
181182 }
182183 for _ , opt := range options {
183184 opt (& c )
184185 }
185- channel := http .NewChannel (serviceURL .JoinPath (claimsPath ), http .WithClient (c .httpClient ))
186+ channel := ucan_http .NewChannel (serviceURL .JoinPath (claimsPath ), ucan_http .WithClient (c .httpClient ))
186187 conn , err := client .NewConnection (servicePrincipal , channel )
187188 if err != nil {
188189 return nil , fmt .Errorf ("creating connection: %w" , err )
0 commit comments