You need to enable JavaScript to run this app.
TrafficRoute DNS Suite

TrafficRoute DNS Suite

Copy page
Download PDF
Best Practices
Add custom identifiers to AnyMatch functionality
Copy page
Download PDF
Add custom identifiers to AnyMatch functionality
This document describes how to add a custom identifier for the AnyMatch feature of Software-defined Resolution using the HTTPDNS SDK.​
Add custom identifiers in Android SDK​
You can add custom identifiers for the AnyMatch feature for software-defined parsing in Android SDK version 1.0.22 or later.​
  1. Import the AbsOptionalHttpDnsDepend abstract class.​
​
import AbsOptionalHttpDnsDepend;​
​
  1. When initializing the Android SDK, inherit the AbsOptionalHttpDnsDepend abstract class and override the getExtraHeaders method or the getExtraQueryParams method. Then, you need to pass a custom identifier in the return value.​
tip​
  • getExtraHeaders method sends a custom identifier via request headers; getExtraQueryParams method sends a custom identifier via query parameters. You can choose any one of these methods.​
  • You can add multiple custom identifiers in Am-Tag. The matching order is from left to right. For example, in headers.put("Am-Tag", Arrays.asList("hebei", "shijiazhuang")), the matching order is hebei and shijiazhuang.​
​
public class TestHttpDnsDepend extends AbsOptionalHttpDnsDepend implements IHttpDnsDepend {​
​
...​
​
@Override​
public Map<String, List<String>> getExtraHeaders() {​
Map<String, List<String>> headers = new HashMap<>();​
headers.put("Am-Tag", Arrays.asList("aaa", "bbb"));​
headers.put("Am-Id", Arrays.asList("123"));​
return headers;​
}​
​
@Override​
public Map<String, List<String>> getExtraQueryParams() {​
Map<String, List<String>> querys = new HashMap<>();​
querys.put("amtag", Arrays.asList("aaa", "bbb"));​
querys.put("amid", Arrays.asList("123"));​
return querys;​
}​
​
}​
​
Add custom identifiers in the iOS SDK​
You can add custom identifiers for the software-defined parsing AnyMatch feature in iOS SDK version 0.13.1 or later.​
When initializing the iOS SDK, before calling dnsResolverColdStart, call setHttpDnsCustomHeaderBlock or setHttpDnsCustomParamBlock to send a custom identifier.​
tip​
  • setHttpDnsCustomHeaderBlock method sends a custom identifier via the request header; setHttpDnsCustomParamBlock method sends a custom identifier via query parameters. You may choose any one of the methods.​
  • You can add multiple custom identifiers in the Am-Tag. The matching order is from left to right. For example, in "Am-Tag" : ["hebei", "shijiazhuang"], the matching order is hebei and shijiazhuang.​
​
[[TTDnsResolver shareInstance] setHttpDnsCustomHeaderBlock:^NSDictionary * (NSArray<NSString*>* hosts) {​
return @{@"Am-Tag" : @[@"aaa", @"bbb"],​
@"Am-Id": [NSNumber numberWithLongLong:1234567]};​
}];​
​
[[TTDnsResolver shareInstance] setHttpDnsCustomParamBlock:^NSDictionary * (NSArray<NSString*>* hosts) {​
return @{@"amtag" : @[@"aaa", @"bbb"],​
@"amid": [NSNumber numberWithLongLong:1234567]};​
}];​
​
​
Last updated: 2025.11.04 21:10:49