Repository navigation
Conversation
…aders Send signed URL upload requests without client-level headers.
There was a problem hiding this comment.
Code Review
This pull request adds support for signed URLs in resumable uploads, ensuring that client headers (such as authorization and custom headers) are excluded when writing to a signed URL. To support this, a new forSignedUrl factory method is added to HttpClientContext, and HttpStorageRpc is updated to manage a dedicated signedUrlRequestFactory. However, a critical issue was identified in HttpClientContext.forSignedUrl: the method accepts a StorageRpc parameter but attempts to call getStorage(), which is not defined on the StorageRpc interface. It is recommended to change the parameter type to HttpStorageRpc directly to ensure compile-time safety.
| static HttpClientContext forSignedUrl(StorageRpc storageRpc) { | ||
| HttpRequestFactory requestFactory = | ||
| storageRpc instanceof HttpStorageRpc | ||
| ? ((HttpStorageRpc) storageRpc).getSignedUrlRequestFactory() | ||
| : storageRpc.getStorage().getRequestFactory().getTransport().createRequestFactory(); | ||
| return new HttpClientContext( | ||
| requestFactory, storageRpc.getStorage().getObjectParser(), Tracing.getTracer()); | ||
| } |
There was a problem hiding this comment.
The current implementation of forSignedUrl will fail to compile because storageRpc is declared as StorageRpc, which does not define the getStorage() method. Since HttpClientContext is specific to HTTP transport, we should use HttpStorageRpc as the parameter type directly to ensure compile-time safety, rather than generalizing to StorageRpc and casting.
static HttpClientContext forSignedUrl(HttpStorageRpc storageRpc) {
return new HttpClientContext(
storageRpc.getSignedUrlRequestFactory(),
storageRpc.getStorage().getObjectParser(),
Tracing.getTracer());
}References
- Use specific transport classes as parameter types for helper methods designed to run on top of that specific transport to ensure compile-time safety, rather than generalizing to a generic class.
Send signed URL upload requests without client-level headers.