Skip to content

Commit bdb0896

Browse files
author
Matthias Thomae
committed
Add support for UAProf header in HTTP requests
Each HTTP request sent from a mobile handset is usually required to include a x-wap-profile header following the UAProf specification. The value of this header is a URL that points to the location of a document which specifies relevant capabilities of the phone, e.g. supported network bearers, video formats or screen size. This change defines a global string resource that holds this URL, and also adds the necessary code in the web widget to include this header in HTTP requests.
1 parent c1c45a4 commit bdb0896

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

core/java/android/webkit/FrameLoader.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
import android.net.http.EventHandler;
2020
import android.net.http.RequestHandle;
21+
import android.os.Build;
2122
import android.util.Log;
2223
import android.webkit.CacheManager.CacheResult;
2324

@@ -35,6 +36,7 @@ class FrameLoader {
3536
private int mCacheMode;
3637
private String mReferrer;
3738
private String mContentType;
39+
private final String mUaprofHeader;
3840

3941
private static final int URI_PROTOCOL = 0x100;
4042

@@ -57,6 +59,8 @@ class FrameLoader {
5759
mMethod = method;
5860
mCacheMode = WebSettings.LOAD_NORMAL;
5961
mSettings = settings;
62+
mUaprofHeader = mListener.getContext().getResources().getString(
63+
com.android.internal.R.string.config_useragentprofile_url, Build.MODEL);
6064
}
6165

6266
public void setReferrer(String ref) {
@@ -356,6 +360,11 @@ private void populateStaticHeaders() {
356360
}
357361

358362
mHeaders.put("User-Agent", mSettings.getUserAgentString());
363+
364+
// Set the x-wap-profile header
365+
if (mUaprofHeader != null && mUaprofHeader.length() > 0) {
366+
mHeaders.put("x-wap-profile", mUaprofHeader);
367+
}
359368
}
360369

361370
/**

core/res/res/values/config.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,4 +332,11 @@
332332
<!-- 2 means give warning -->
333333
<integer name="config_datause_notification_type">2</integer>
334334

335+
<!-- The URL that should be sent in an x-wap-profile header with an HTTP request,
336+
as defined in the Open Mobile Alliance User Agent Profile specification
337+
OMA-TS-UAProf-V2_0-20060206-A Section 8.1.1.1. If the URL contains a '%s'
338+
format string then that substring will be replaced with the value of
339+
Build.MODEL. The format string shall not be escaped. -->
340+
<string name="config_useragentprofile_url"></string>
341+
335342
</resources>

0 commit comments

Comments
 (0)