Skip to content

Commit 82c45dc

Browse files
Add GMPID setting
1 parent 3ffa95f commit 82c45dc

File tree

5 files changed

+16
-0
lines changed

5 files changed

+16
-0
lines changed

firebase-database/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
# Unreleased
2+
3+
- [changed] Added internal HTTP header to the WebChannel connection.
4+
5+
# 19.3.0
26
- [feature] Added ServerValue.increment() to support atomic field value increments
37
without transactions.
48

firebase-database/src/main/java/com/google/firebase/database/connection/ConnectionContext.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ public class ConnectionContext {
2424
private final boolean persistenceEnabled;
2525
private final String clientSdkVersion;
2626
private final String userAgent;
27+
private final String applicationId;
2728
private final String sslCacheDirectory;
2829

2930
public ConnectionContext(
@@ -33,13 +34,15 @@ public ConnectionContext(
3334
boolean persistenceEnabled,
3435
String clientSdkVersion,
3536
String userAgent,
37+
String applicationId,
3638
String sslCacheDirectory) {
3739
this.logger = logger;
3840
this.authTokenProvider = authTokenProvider;
3941
this.executorService = executorService;
4042
this.persistenceEnabled = persistenceEnabled;
4143
this.clientSdkVersion = clientSdkVersion;
4244
this.userAgent = userAgent;
45+
this.applicationId = applicationId;
4346
this.sslCacheDirectory = sslCacheDirectory;
4447
}
4548

@@ -70,4 +73,8 @@ public String getUserAgent() {
7073
public String getSslCacheDirectory() {
7174
return sslCacheDirectory;
7275
}
76+
77+
public String getApplicationId() {
78+
return applicationId;
79+
}
7380
}

firebase-database/src/main/java/com/google/firebase/database/connection/PersistentConnectionImpl.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,7 @@ private enum ConnectionState {
244244
private final Delegate delegate;
245245
private final HostInfo hostInfo;
246246
private String cachedHost;
247+
private String applicationId;
247248
private HashSet<String> interruptReasons = new HashSet<String>();
248249
private boolean firstConnection = true;
249250
private long lastConnectionEstablishedTime;
@@ -280,6 +281,7 @@ public PersistentConnectionImpl(
280281
this.context = context;
281282
this.executorService = context.getExecutorService();
282283
this.authTokenProvider = context.getAuthTokenProvider();
284+
this.applicationId = context.getApplicationId();
283285
this.hostInfo = info;
284286
this.listens = new HashMap<ListenQuerySpec, OutstandingListen>();
285287
this.requestCBHash = new HashMap<Long, ConnectionRequestCallback>();

firebase-database/src/main/java/com/google/firebase/database/connection/WebsocketConnection.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,8 @@ private WSClient createConnection(
186186
host, hostInfo.isSecure(), hostInfo.getNamespace(), optLastSessionId);
187187
Map<String, String> extraHeaders = new HashMap<String, String>();
188188
extraHeaders.put("User-Agent", this.connectionContext.getUserAgent());
189+
extraHeaders.put("X-Firebase-GMPID", this.connectionContext.getApplicationId());
190+
189191
WebSocket ws = new WebSocket(this.connectionContext, uri, /*protocol=*/ null, extraHeaders);
190192
WSClientTubesock client = new WSClientTubesock(ws);
191193
return client;

firebase-database/src/main/java/com/google/firebase/database/core/Context.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ public ConnectionContext getConnectionContext() {
145145
this.isPersistenceEnabled(),
146146
FirebaseDatabase.getSdkVersion(),
147147
this.getUserAgent(),
148+
firebaseApp.getOptions().getApplicationId(),
148149
this.getSSLCacheDirectory().getAbsolutePath());
149150
}
150151

0 commit comments

Comments
 (0)