Skip to content

Commit

Permalink
Send agent name from THeaderTransport.java
Browse files Browse the repository at this point in the history
Summary: One downside of this implementation is that this will be sent with the first response from the Java server as well. But I don't think any clients should care.

Reviewed By: mshneer

Differential Revision: D30954223

fbshipit-source-id: bbdf944ca98c6a159a26ee6e3ece1bc4ec457453
  • Loading branch information
andriigrynenko authored and facebook-github-bot committed Sep 15, 2021
1 parent 9053597 commit b3c7050
Showing 1 changed file with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,13 @@ public int getValue() {
private static final String IDENTITY_HEADER = "identity";
private static final String ID_VERSION_HEADER = "id_version";
private static final String ID_VERSION = "1";
private static final String CLIENT_METADATA_HEADER = "client_metadata";
private static final String CLIENT_METADATA = "{\"agent\":\"THeaderTransport.java\"}";

private String identity;

private boolean firstRequest = true;

public THeaderTransport(TTransport transport) {
super(transport);
writeTransforms = new ArrayList<Transforms>();
Expand Down Expand Up @@ -431,6 +435,7 @@ private void readHeaderFormat(int headerSize, byte[] buff) throws TTransportExce
break;
}
}
readHeaders.remove(CLIENT_METADATA_HEADER);
readHeaders.putAll(readPersistentHeaders);

// Read in the data section.
Expand Down Expand Up @@ -614,6 +619,11 @@ public void flushImpl(boolean oneway) throws TTransportException {
transformData.limit(transformData.position());
transformData.position(0);

if (firstRequest) {
firstRequest = false;
writeHeaders.put(CLIENT_METADATA_HEADER, CLIENT_METADATA);
}

if (identity != null && identity.length() > 0) {
writeHeaders.put(ID_VERSION_HEADER, ID_VERSION);
writeHeaders.put(IDENTITY_HEADER, identity);
Expand Down

0 comments on commit b3c7050

Please sign in to comment.