fake the useragent for air-canada
This commit is contained in:
parent
2c63aa8631
commit
0acd280f61
2 changed files with 41 additions and 1 deletions
|
@ -100,6 +100,33 @@
|
|||
|
||||
<data android:mimeType="application/vnd-com.apple.pkpass" />
|
||||
</intent-filter>
|
||||
|
||||
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.VIEW" />
|
||||
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
<category android:name="android.intent.category.BROWSABLE" />
|
||||
|
||||
<data
|
||||
android:host="m.aircanada.ca"
|
||||
android:pathPattern="/ebp/.*"
|
||||
android:scheme="http" />
|
||||
</intent-filter>
|
||||
|
||||
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.VIEW" />
|
||||
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
<category android:name="android.intent.category.BROWSABLE" />
|
||||
|
||||
<data
|
||||
android:host="m.aircanada.ca"
|
||||
android:pathPattern="/ebp/.*"
|
||||
android:scheme="https" />
|
||||
</intent-filter>
|
||||
|
||||
</activity>
|
||||
|
||||
<activity
|
||||
|
|
|
@ -17,11 +17,24 @@ import java.net.MalformedURLException;
|
|||
import java.net.URL;
|
||||
|
||||
public class InputStreamProvider {
|
||||
|
||||
public static final String IPHONE_USER_AGENT = "Mozilla/5.0 (iPhone; CPU iPhone OS 7_0 like Mac OS X; en-us) AppleWebKit/537.51.1 (KHTML, like Gecko) Version/7.0 Mobile/11A465 Safari/9537.53";
|
||||
|
||||
public final static InputStreamWithSource fromOKHttp(final Uri uri) {
|
||||
try {
|
||||
final OkHttpClient client = new OkHttpClient();
|
||||
final URL url = new URL(uri.toString());
|
||||
Request request = new Request.Builder().url(url).build();
|
||||
final Request.Builder requestBuilder = new Request.Builder().url(url);
|
||||
|
||||
// fake to be an iPhone in some cases when the server decides to send no passbook
|
||||
// to android phones - but only do it then - we are proud to be Android ;-)
|
||||
if (uri.toString().contains("//m.aircanada.ca/ebp/")) {
|
||||
Tracker.get().trackEvent("quirk_fix", "ua_fake", "air_canada", null);
|
||||
requestBuilder.header("User-Agent", IPHONE_USER_AGENT);
|
||||
}
|
||||
|
||||
final Request request = requestBuilder.build();
|
||||
|
||||
final Response response = client.newCall(request).execute();
|
||||
|
||||
return new InputStreamWithSource(uri.toString(), response.body().byteStream());
|
||||
|
|
Loading…
Reference in a new issue