![]()
Working with Headers
You can access the HTTP header fields of a URL loaded by your application by listening for the contentLoading request.
The oldvalue is a ContentLoader object. If you do a getURLConnection( ) on that object when the HTTP subsystem is active, an ice.net.HttpURLConnection is returned. The connection contains header fields after the contentLoading, begin event has fired.
For example, open the /tutorial/step04/MyBrowser.java file, and look for the propertyChange (PropertyChangeEvent event) method.
You could add the following code at the beginning of the method:
if (propertyName.equals(PropertyConstants.CONTENT_LOADING) && newValue.equals(PropertyConstants.REQUEST)) { ContentLoader contentLoader = (ContentLoader)event.getOldValue(); ice.net.HttpURLConnection httpUrlConnection = (ice.net.HttpURLConnection)contentLoader.getURLConnection(); System.out.println(httpUrlConnection); }For more information, see Working with Property Change Events.
You can specify your own headers in an HTTP request. To do this, use HttpURLConnection.setDefaultRequestProperty(String key, String value).
|
Copyright 2005. ICEsoft Technologies, Inc. http://www.icesoft.com |