mirror of https://github.com/grpc/grpc-java.git
okhttp: generate user agent once for whole transport
This commit is contained in:
parent
f172170649
commit
ca8e166591
|
@ -46,8 +46,6 @@ import okio.ByteString;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* Constants for request/response headers.
|
||||
*/
|
||||
|
@ -65,7 +63,7 @@ public class Headers {
|
|||
* application thread context.
|
||||
*/
|
||||
public static List<Header> createRequestHeaders(Metadata headers, String defaultPath,
|
||||
String authority, @Nullable String applicationUserAgent) {
|
||||
String authority, String userAgent) {
|
||||
Preconditions.checkNotNull(headers, "headers");
|
||||
Preconditions.checkNotNull(defaultPath, "defaultPath");
|
||||
Preconditions.checkNotNull(authority, "authority");
|
||||
|
@ -81,7 +79,6 @@ public class Headers {
|
|||
String path = defaultPath;
|
||||
okhttpHeaders.add(new Header(Header.TARGET_PATH, path));
|
||||
|
||||
String userAgent = GrpcUtil.getGrpcUserAgent("okhttp", applicationUserAgent);
|
||||
okhttpHeaders.add(new Header(GrpcUtil.USER_AGENT_KEY.name(), userAgent));
|
||||
|
||||
// All non-pseudo headers must come after pseudo headers.
|
||||
|
|
|
@ -96,7 +96,7 @@ class OkHttpClientStream extends Http2ClientStream {
|
|||
Object lock,
|
||||
int maxMessageSize,
|
||||
String authority,
|
||||
@Nullable String userAgent) {
|
||||
String userAgent) {
|
||||
super(new OkHttpWritableBufferAllocator(), maxMessageSize);
|
||||
this.method = method;
|
||||
this.headers = headers;
|
||||
|
|
|
@ -183,7 +183,7 @@ class OkHttpClientTransport implements ManagedClientTransport {
|
|||
this.sslSocketFactory = sslSocketFactory;
|
||||
this.connectionSpec = Preconditions.checkNotNull(connectionSpec, "connectionSpec");
|
||||
this.ticker = Ticker.systemTicker();
|
||||
this.userAgent = userAgent;
|
||||
this.userAgent = GrpcUtil.getGrpcUserAgent("okhttp", userAgent);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -197,7 +197,7 @@ class OkHttpClientTransport implements ManagedClientTransport {
|
|||
address = null;
|
||||
this.maxMessageSize = maxMessageSize;
|
||||
defaultAuthority = "notarealauthority:80";
|
||||
this.userAgent = userAgent;
|
||||
this.userAgent = GrpcUtil.getGrpcUserAgent("okhttp", userAgent);
|
||||
this.executor = Preconditions.checkNotNull(executor);
|
||||
serializingExecutor = new SerializingExecutor(executor);
|
||||
this.testFrameReader = Preconditions.checkNotNull(frameReader);
|
||||
|
|
Loading…
Reference in New Issue