Friday, May 1, 2009

HTTP User-Agent from Nokia E71

pencil icon, that"s clickable to start editing the post

At work I have the pleasure of using a Nokia E71. I wanted to try out Google Maps for mobile as an alterntive to the nokia maps. The only way was to visit google through the browser in E71, and that way detect the device. It intrigued me to figure out how the UserAgent looked like, and be able to fake it with User Agent Switcher.

E71 Specification

Before just showing what turns up in the log files, here's what can be figured out from the specifications. The specification for Nokia E71 states that the Software platform and user interface uses S60 3.1 Edition, Eseries (Symbian Os 9.2). It lists the following features for Web browsing:

  • Supported markup languages: HTML, XHTML, MP, WML, CSS
  • Supported protocols: HTTP, WAP 2.0
  • TCP/IP support
  • Nokia browser
    • JavaScript version 1.3 and 1.5
    • Mini Map
  • Nokia Mobile Search
  • Nokia PC Internet Access (capability to serve as a data modem)

The Open Mobile Alliance(OMA) has defined and RDF Schema for technical device profiles and on their page for OMA Profile Data the UAProf V1.1 Candidate File (ccppschema-20021212) can be found. The specific profile for E71 has been long known and can be fetched at http://nds1.nds.nokia.com/uaprof/NE71-1r100.xml. In a comment block the User Agent is given:

 
<!-- ===================================================== -->
<!--                                                       -->

<!-- Version 1.1 16 Jul 2008                               -->
<!--                                                       -->
<!-- Valid beginning from version 1.00.0                   -->
<!-- User Agent Header: Mozilla/5.0(SymbianOS/9.2; U;      -->
<!--  Series60/3.1 NokiaE71/1.00.000; Profile/MIDP-2.0     -->
<!--  Configuration/CLDC-1.1;)AppleWebKit/413(KHTML,       -->
<!--  like Gecko)Safari/413                                -->
<!-- ===================================================== -->

User-Agent according to RFC 2616

In terms of HTTP RFC 2616 defines the User-Agent header. The W3C has a somewhat more accessible version than the plain IETF version: RFC 2616 - "Hypertext Transfer Protocol -- HTTP/1.1" and specific in "14.43 User-Agent":

The User-Agent request-header field contains information about the user agent originating the request. This is for statistical purposes, the tracing of protocol violations, and automated recognition of user agents for the sake of tailoring responses to avoid particular user agent limitations. User agents SHOULD include this field with requests. The field can contain multiple product tokens (section 3.8) and comments identifying the agent and any subproducts which form a significant part of the user agent. By convention, the product tokens are listed in order of their significance for identifying the application.

User-Agent = "User-Agent" ":" 1*( product | comment )

Example:

User-Agent: CERN-LineMode/2.15 libwww/2.17b3

The User-Agent's

My current User-Agent is:

"Mozilla/5.0 (SymbianOS/9.2; U; Series60/3.1 NokiaE71-1/110.07.127; Profile/MIDP-2.0 Configuration/CLDC-1.1 ) AppleWebKit/413 (KHTML, like Gecko) Safari/413"

The UAProfile was:

"Mozilla/5.0(SymbianOS/9.2; U;  Series60/3.1 NokiaE71/1.00.000; Profile/MIDP-2.0 Configuration/CLDC-1.1;)AppleWebKit/413(KHTML, like Gecko)Safari/413"

I've aerlier looked at The UserAgent Signature from the Google Chrome browser_

Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/525.19 (KHTML, like Gecko) Chrome/1.0.154.59 Safari/525.19

or

Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/525.13 (KHTML, like Gecko) Chrome/0.2.149.27 Safari/525.13

Where Firefox can look like:

Mozilla/5.0 (Windows; U; Windows NT 5.1; da; rv:1.9.0.10) Gecko/2009042316 Firefox/3.0.10

or

Mozilla/5.0 (Windows; U; Windows NT 5.1; da; rv:1.9.0.1) Gecko/2008070208 Firefox/3.0.1

or

Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.16) Gecko/20080702 Firefox/2.0.0.16

Internet Explorer shows up like:

Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 2.0.50727; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022)

or

Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; Trident/4.0; SLCC1; .NET CLR 2.0.50727; Media Center PC 5.0; .NET CLR 3.5.30729; .NET CLR 3.0.30618; InfoPath.2)

or

Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322; .NET CLR 2.0.50727; InfoPath.2)

Read more

Wednesday, April 8, 2009

Efficient XML is in fact efficient!

pencil icon, that"s clickable to start editing the post

In the beginning of 2008 I wrote on "W3C drafts on Efficient XML Interchange, EXI - I didn't say binary XML". The specification is now a last call working draft from 19 September 2008. There has been both implementation and a test suite developed to test whether it in fact is efficient - and if you browse through their "Efficient XML Interchange Evaluation" you'll discover that in fact it is. They have also done a "Efficient XML Interchange (EXI) Impacts" analysis, and this conclusion is also positive:

EXI has been designed to be compatible with XML and can be introduced into the existing family of XML technologies without immediate disruption to XML-using applications. However, with certain modifications to existing XML-related specifications in the future it may be possible to achieve additional benefits when using EXI, still without disruption to existing XML-based applications. Furthermore, in a multi-application system where only some applications adopt EXI, sending EXI data to the other applications can potentially cause disruption, so care is needed to account for differing format support among the participating applications.

In terms of efficiency they have done various tests. I haven't looked into the test cases nor the technologies used for comparison but hope it's done as serious as the document looks like. They hav benchmarked it to existing technologies like Gzipped XML and ASN.1 for compactness.

...EXI is consistently smaller than gzipped XML regardless of document size, document structure or the availability of schema information. In some cases, EXI is over 10 times smaller than gzip. In addition, EXI works well in cases where gzip has little effect or even makes documents bigger, such as high volume streams of small messages typical of geolocation, financial exchange and sensor applications.

and

... Each EXI encoded file is smaller than the equivalent ASN.1 PER, and sometimes 20 times smaller. This holds true even for cases where EXI is preserving XML comments, processing instructions and namespace prefixes that are not preserved by ASN.1 PER. In addition, EXI works well in cases where ASN.1 PER actually increases the size of the document or fails to produce an encoding at all (e.g., due to schema deviations.)

Size is one thing but it could come at a processing cost, so they've tested that as well

The average decoding speed of EXI was 14.5 times faster than the average decoding speed of XML. The median speed increase was 6.7 times faster. To improve readibility, the graph does not show the four best cases, which ranged from 54 times faster to 257 times faster. These four test cases were SOAP web-service messages that were marshalled from a binding layer and contained repeating structures with elements and attributes from several different namespaces. As is typical for such use cases, the repeated structures contained a large number of repeated namespace declarations. EXI eliminates most of the overhead associated with namespace processing, which is why EXI achieved such a speed increase for these cases.

I guess these namespace declarations could be optimized just placing them at the root level, but I'm not sure if this would speed up the processing (and that i hurt that bad).

The graph above shows EXI decoding speed with compression compared to XML with compression. The average decoding speed of EXI was 9.2 times faster than the average decoding speed of GZipped XML. The median speed was 4.4 times faster. ...

Summary

I sure looks like EXI is comming to an end with a final working draft and test suite that ran with success. It will be interesting to see if it actually picks up speed and when? I haven't found any open source implementations yet. EXI may loose out due to not but good enough but from competition from Advanced Message Queuing Protocol, that goes for the same kind of nails and maybe fits a larger user base of classic messaging.

Read more

Monday, April 6, 2009

Updating my wireless Linksys devices

pencil icon, that"s clickable to start editing the post

The wonders of wireless network access are nothing short of fantastic. The only drawbacks in comparison to the wired variant would be that they need configuration (and not just cables) and that it introduces a new security risk. I try to maintain level of security, which also involves having non-trivial passwords - great for security but I have to remember them, and from time to time I fail on that. Though keeping an updated firmware has become more important since it has become a target for viruses and trojans. This post is a short writeup on my notes getting my wireless network up and running again.

Linksys WPS54G

I have just changed my ISP and swapped back to my old Linksys router and that went fine. It was when I wanted to updated my wireless printer server that ughh, no password no update. My printserver is a Linksys WPS54G (Version 2.0):

The data sheet can tell you about all the goodies, but I will say that from time to time I've seen some strange behavior with the administrator interfacer and read postings that suggest using IE 5 or a browser that faked that. My experience is also that when you got configured right and running it works like a charm.

I first had to reset it and according to the manual is should happen after pressing the reset button for about 10 seconds, that didn't work for me just printed the current configuration each time, but doing a unplug/plug followed by a reset did. I then used the desktop program to configure it, since I knew that the web-interface can be flaky. The configuration went without problems but do note that the default password is admin (without usename) but after changing the password the username has to be admin used with the new password.

I also updated the firmware version 6051 (08/21/2008) without any problems.

Linksys WRT54GS

While I was at it I had decided to updated the SSID and security model to WPA2(AES) so I also reconfigured my router a Linksys WRT54GS (version 1.1), that has served me well for a long time:

The password thing is just the same as with the WPS54G. I updated the firmware to Version 4.71.4, which according to the website was from 03/13/2008, but the router said 10/31/2007.

Read more

Saturday, March 28, 2009

Running my own SMS Service with Kannel and HUAWEI E180

pencil icon, that"s clickable to start editing the post

Mobile Services are becomming more and more common. Seven years ago I had the opportunity to develop some simpel SMS services, and SMS services is still the most common form of Mobile Services, though the mobile web is picking up momentum as well as custom Mobile Aplications. I decided to have a look at Mobile Services and to start with building a simple SMS Service. This blog post vil cover the basic setup and a later post the service part itself (though it's fairly easy).

Back in 2002 the company I worked for used both a commercial SMSC with billing etc., but we also ran our own SMSC to receive data carried by SMS. For our own SMSC we used Kannel which was quite easy to setup and run. I was please to see the Kannel project is still running.

I started by downloading the lastest stable release (version 1.4.3). Installing on my Fedora 10 Linux distribution was an easy classic ./configure, make, make install. The binary distribution comes with a sample SMSC configuration in the gw/smskannel.conf file. I only needed to update it with my local settings which involved figuring out the way to hook it up to my modem (the only part that was a bit problematic back then with a serial interface).

The Huawei E180 Modem

I have a Mobile Broadband ISP (flatrate) that comes with a USB modem (3G). The modem has the name E180, and can be seen on the Huawei device website HUAWEI E180 - HSPA USB Stick. The short specification list is: Support 2Mbps (5.76Mbps ready) HSUPA and 7.2Mbps HSDPA services Support SMS and Voice services. To find the manual is quite har since it's not available from Huawei's own support site, so through Google I found it [PDF] at the South African company Maredi's website. It carries the subtitle as flexiable as wings and it certainly is easy to use on both Linux and Windows, though I'm not sure I really like the metaphor on airplane wings.

After I insert the modem into a USB port the messages log showes something like:

Mar 28 07:47:11 kannel kernel: usb 2-1: new high speed USB device using ehci_hcd and address 3
Mar 28 07:47:11 kannel kernel: usb 2-1: configuration #1 chosen from 1 choice                 
Mar 28 07:47:11 kannel kernel: scsi3 : SCSI emulation for USB Mass Storage devices            
Mar 28 07:47:11 kannel kernel: scsi4 : SCSI emulation for USB Mass Storage devices            
Mar 28 07:47:11 kannel kernel: usb 2-1: New USB device found, idVendor=12d1, idProduct=1003   
Mar 28 07:47:11 kannel kernel: usb 2-1: New USB device strings: Mfr=2, Product=1, SerialNumber=0
Mar 28 07:47:11 kannel kernel: usb 2-1: Product: HUAWEI Mobile                                  
Mar 28 07:47:11 kannel kernel: usb 2-1: Manufacturer: HUAWEI Technology                         
Mar 28 07:47:11 kannel kernel: usb 2-1: USB disconnect, address 3                               
Mar 28 07:47:11 kannel pulseaudio[3309]: module-hal-detect.c: Error getting capability: org.freedesktop.Hal.NoSuchDevice: No device with id /org/freedesktop/Hal/devices/usb_device_ffffffff_ffffffff_noserial_scsi_host                                     
Mar 28 07:47:11 kannel pulseaudio[3309]: module-hal-detect.c: Error getting capability: org.freedesktop.Hal.NoSuchDevice: No device with id /org/freedesktop/Hal/devices/usb_device_ffffffff_ffffffff_noserial_0_scsi_host                                   
Mar 28 07:47:17 kannel kernel: usb 2-1: new high speed USB device using ehci_hcd and address 4                                 
Mar 28 07:47:17 kannel kernel: usb 2-1: configuration #1 chosen from 1 choice                                                  
Mar 28 07:47:17 kannel kernel: usb-storage: probe of 2-1:1.0 failed with error -5                                              
Mar 28 07:47:17 kannel kernel: usb-storage: probe of 2-1:1.1 failed with error -5                                              
Mar 28 07:47:18 kannel kernel: scsi7 : SCSI emulation for USB Mass Storage devices                                             
Mar 28 07:47:19 kannel kernel: scsi8 : SCSI emulation for USB Mass Storage devices                                             
Mar 28 07:47:19 kannel kernel: usb 2-1: New USB device found, idVendor=12d1, idProduct=1003                                    
Mar 28 07:47:19 kannel kernel: usb 2-1: New USB device strings: Mfr=2, Product=1, SerialNumber=0
Mar 28 07:47:19 kannel kernel: usb 2-1: Product: HUAWEI Mobile
Mar 28 07:47:19 kannel kernel: usb 2-1: Manufacturer: HUAWEI Technology
Mar 28 07:47:19 kannel kernel: usbcore: registered new interface driver usbserial
Mar 28 07:47:19 kannel kernel: usbserial: USB Serial support registered for generic
Mar 28 07:47:19 kannel kernel: usbcore: registered new interface driver usbserial_generic
Mar 28 07:47:19 kannel kernel: usbserial: USB Serial Driver core
Mar 28 07:47:19 kannel kernel: usbserial: USB Serial support registered for GSM modem (1-port)
Mar 28 07:47:19 kannel kernel: option 2-1:1.0: GSM modem (1-port) converter detected
Mar 28 07:47:19 kannel kernel: usb 2-1: GSM modem (1-port) converter now attached to ttyUSB0
Mar 28 07:47:19 kannel kernel: option 2-1:1.1: GSM modem (1-port) converter detected
Mar 28 07:47:19 kannel kernel: usb 2-1: GSM modem (1-port) converter now attached to ttyUSB1
Mar 28 07:47:19 kannel kernel: usbcore: registered new interface driver option
Mar 28 07:47:19 kannel kernel: option: USB Driver for GSM modems: v0.7.2
Mar 28 07:47:23 kannel kernel: scsi 7:0:0:0: CD-ROM            HUAWEI   Mass Storage     2.31 PQ: 0 ANSI: 2
Mar 28 07:47:23 kannel kernel: sr0: scsi-1 drive
Mar 28 07:47:23 kannel kernel: Uniform CD-ROM driver Revision: 3.20
Mar 28 07:47:23 kannel kernel: sr 7:0:0:0: Attached scsi generic sg2 type 5
Mar 28 07:47:24 kannel kernel: scsi 8:0:0:0: Direct-Access     HUAWEI   SD Storage       2.31 PQ: 0 ANSI: 2
Mar 28 07:47:24 kannel kernel: sd 8:0:0:0: [sdc] Attached SCSI removable disk
Mar 28 07:47:24 kannel kernel: sd 8:0:0:0: Attached scsi generic sg3 type 0
Mar 28 07:47:25 kannel NetworkManager:   (ttyUSB0): detected GSM modem via HAL capabilities
Mar 28 07:47:25 kannel NetworkManager:   (ttyUSB0): new Modem device (driver: 'option')
Mar 28 07:47:25 kannel NetworkManager:   (ttyUSB0): exported as /org/freedesktop/Hal/devices/usb_device_12d1_1003_noserial_if0_serial_usb_0
Mar 28 07:47:29 kannel NetworkManager:   (ttyUSB0): device state change: 1 -> 2
Mar 28 07:47:29 kannel NetworkManager:   (ttyUSB0): deactivating device (reason: 2).

Configure and run Bearerbox

The bearerbox part of the example configuration with just the needed changes, configuring the bearerbox and the two SMSC connections, the first one the fake SMSC and the other one my virtual SMSC based on my Huawei E180 modem:

# Needed - otherwise Kannel Bearerbox could not configure the modem correctly
include = doc/examples/modems.conf                                       

#---------------------------------------------                           
# CORE                                                                   
#---------------------------------------------                           
group = core
admin-port = 13000
smsbox-port = 13001
admin-password = bar
box-deny-ip = "*.*.*.*"      
box-allow-ip = "127.0.0.1"   

#---------------------------------------------
# SMSC CONNECTIONS                            
#                                             
# SMSC connections are created in bearerbox and they handle SMSC specific
# protocol and message relying. You need these to actually receive and send
# messages to handset, but can use GSM modems as virtual SMSCs             

# This is a fake smsc connection, _only_ used to test the system and services.
# It really cannot relay messages to actual handsets!                         
group = smsc
smsc = fake 
smsc-id = FAKE
port = 10000  
connect-allow-ip = 127.0.0.1


# My own 'virtual' SMSC with the HUAWEI E169 
group = smsc
smsc = at   
modemtype = auto
device = /dev/ttyUSB1
my-number = [TheTelephoneNumberOnTheSIM]
log-level = 0        
pin = [ThePINofTheSIM]

The Bearerbox is started with /opt/kannel-1.4.3/sbin/bearerbox -v 1 /home/kannel/Download/gateway-1.4.3/gw/smskannel.conf and the output is:

2009-03-28 07:55:26 [4193] [0] INFO: Debug_lvl = 1, log_file = , log_lvl = 0
2009-03-28 07:55:26 [4193] [0] WARNING: DLR: using default 'internal' for storage type.
2009-03-28 07:55:26 [4193] [0] INFO: DLR using storage type: internal
2009-03-28 07:55:26 [4193] [0] INFO: HTTP: Opening server at port 13000.
2009-03-28 07:55:26 [4193] [0] INFO: BOXC: 'smsbox-max-pending' not set, using default (100).
2009-03-28 07:55:26 [4193] [0] INFO: Set SMS resend frequency to 60 seconds.
2009-03-28 07:55:26 [4193] [0] INFO: SMS resend retry set to unlimited.
2009-03-28 07:55:26 [4193] [0] INFO: DLR rerouting for smsc id  disabled.
2009-03-28 07:55:26 [4193] [0] INFO: DLR rerouting for smsc id <(null)> disabled.
2009-03-28 07:55:26 [4193] [0] INFO: AT2[/dev/ttyUSB1]: configuration doesn't show modemtype. will autodetect
2009-03-28 07:55:26 [4193] [0] INFO: ----------------------------------------
2009-03-28 07:55:26 [4193] [0] INFO: Kannel bearerbox II version 1.4.3 starting
2009-03-28 07:55:26 [4193] [0] INFO: MAIN: Start-up done, entering mainloop
2009-03-28 07:55:26 [4193] [7] INFO: AT2[/dev/ttyUSB1]: opening device
2009-03-28 07:55:27 [4193] [7] INFO: AT2[/dev/ttyUSB1]: speed set to 115200
2009-03-28 07:55:29 [4193] [7] INFO: AT2[/dev/ttyUSB1]: Closing device
2009-03-28 07:55:29 [4193] [7] INFO: AT2[/dev/ttyUSB1]: detect speed is 115200
2009-03-28 07:55:29 [4193] [7] INFO: AT2[/dev/ttyUSB1]: opening device
2009-03-28 07:55:30 [4193] [7] INFO: AT2[/dev/ttyUSB1]: speed set to 115200
2009-03-28 07:55:32 [4193] [7] INFO: AT2[/dev/ttyUSB1]: Closing device
2009-03-28 07:55:32 [4193] [7] INFO: AT2[/dev/ttyUSB1]: opening device
2009-03-28 07:55:32 [4193] [7] INFO: AT2[/dev/ttyUSB1]: Logging in
2009-03-28 07:55:33 [4193] [7] INFO: AT2[/dev/ttyUSB1]: init device
2009-03-28 07:55:33 [4193] [7] INFO: AT2[/dev/ttyUSB1]: speed set to 115200
2009-03-28 07:55:33 [4193] [7] ERROR: AT2[/dev/ttyUSB1]: Generic error: ERROR
2009-03-28 07:55:33 [4193] [7] INFO: AT2[/dev/ttyUSB1]: cannot enable hardware handshake
2009-03-28 07:55:34 [4193] [7] INFO: AT2[/dev/ttyUSB1]: AT SMSC successfully opened.

Configuring and running the Smsbox

The Userguide has the complete options for SMSBOX configruation and the example configuration is just fine:

#---------------------------------------------
# SMSBOX SETUP                                
#                                             
# Smsbox(es) do higher-level SMS handling after they have been received from
# SMS centers by bearerbox, or before they are given to bearerbox for delivery

group = smsbox
bearerbox-host = 127.0.0.1
sendsms-port = 13013      
global-sender = 13013     
#log-file = "/tmp/smsbox.log"   
#log-level = 0                  

To use the SMSC for pushing SMS the SendSMS-user configuration is needed:

#---------------------------------------------
# SEND-SMS USERS
#
# These users are used when Kannel smsbox sendsms interface is used to
# send PUSH sms messages, i.e. calling URL like
# http://kannel.machine:13013/cgi-bin/sendsms?username=tester&password=foobar...

group = sendsms-user
username = tester
password = foobar
#user-allow-ip = ""

The normal SMS service is the ability to respond to SMS requests (SMS PULL) which is done with SMS-service configurations:

#---------------------------------------------
# SERVICES
#
# These are 'responses' to sms PULL messages, i.e. messages arriving from
# handsets. The response is based on message content. Only one sms-service is
# applied, using the first one to match.

group = sms-service
keyword = nop
text = "You asked nothing and I did it!"

# There should be always a 'default' service. This service is used when no
# other 'sms-service' is applied.

group = sms-service
keyword = default
text = "No service specified"

This is the most simple service just serving a static string (the value of text). The other and dynamic ways to respond to these requests I'll cover in another post.

Now I can start the SMSBox with /opt/kannel-1.4.3/sbin/smsbox -v 1 gw/smskannel.conf

2009-03-28 08:03:44 [4265] [0] INFO: Debug_lvl = 1, log_file = , log_lvl = 0
2009-03-28 08:03:44 [4265] [0] INFO: Service global sender set as '13013'
2009-03-28 08:03:44 [4265] [0] INFO: HTTP: Opening server at port 13013.
2009-03-28 08:03:44 [4265] [0] INFO: Set up send sms service at port 13013
2009-03-28 08:03:44 [4265] [0] INFO: Connected to bearerbox at 127.0.0.1 port 13001.

After starting these two services there are now a total of 4 open ports for fakesmsc, bearerbox and smsbox:

tcp        0      0 0.0.0.0:10000               0.0.0.0:*                   LISTEN
tcp        0      0 0.0.0.0:13000               0.0.0.0:*                   LISTEN
tcp        0      0 0.0.0.0:13001               0.0.0.0:*                   LISTEN
tcp        0      0 0.0.0.0:13013               0.0.0.0:*                   LISTEN

An example message flow

A simple demo can be run with the fakesmsc commandline tool like in ./test/fakesmsc -m 1 "12345678 87654321 text nop [the_parameters]":

2009-03-28 08:05:55 [4277] [0] INFO: Debug_lvl = -1, log_file = , log_lvl = 0
2009-03-28 08:05:55 [4277] [0] INFO: Host localhost Port 10000 interval 1.000 max-messages 1
2009-03-28 08:05:55 [4277] [0] INFO: fakesmsc starting
2009-03-28 08:05:55 [4277] [0] INFO: fakesmsc: sent message 1
2009-03-28 08:05:55 [4277] [0] INFO: Got message 1: <13013 12345678 text No service specified>

The Bearerbox logs:

2009-03-28 08:03:44 [4193] [5] INFO: Client connected from <127.0.0.1>
2009-03-28 08:05:55 [4193] [6] INFO: Fakesmsc client connected from 127.0.0.1

and the smsbox

2009-03-28 08:05:55 [4265] [4] INFO: Starting to service <nop [the_parameters]> from <12345678> to <87654321>

Summary

Using Kannel is still very easy to both compile, configure and run.

Read more

Thursday, March 26, 2009

Updated W3C draft on "Cross-Origin Resource Sharing"

pencil icon, that"s clickable to start editing the post

About a year ago I wrote about W3C draft on a 'policy' to allow webapps to selectively loosen the same-origin restriction and now they've release a new working draft: Cross-Origin Resource Sharing. I haven't checked that status of the project but hopefully they are closing up to the final recommandation after more than a year's work. The only clue is from the section on status of the document where it states It is expected that this document will progress along the W3C Recommendation track, which isn't all that exact.

The abstract defines the essence as:

This document defines a mechanism to enable client-side cross-origin requests. Specifications that want to enable cross-origin requests in an API they define can use the algorithms defined by this specification. If such an API is used on http://example.org resources, a resource on http://hello-world.example can opt in using the mechanism described by this specification (e.g., specifying Access-Control-Allow-Origin: http://example.org as response header), which would allow that resource to be fetched cross-origin from http://example.org.

The specification defines af total of 3 HTTP request headers and 5 HTTP response headers:

  • Origin
  • Access-Control-Request-Method
  • Access-Control-Request-Headers
  • Access-Control-Allow-Origin
  • Access-Control-Max-Age
  • Access-Control-Allow-Credentials
  • Access-Control-Allow-Methods
  • Access-Control-Allow-Headers

I haven't read the specification in great detail but it looks like this will make web 2.0 mashups a lot easier, makeing it possible to make requests to different hosts based on a formal policy. As for inter-document interactions like in iframe scenarios I'm not sure, but I think it follows along since if to hostnames declare that they are an associated common domman I would expect these restraints to loosen as well freeing us for using semi-dirty hacks like double iframe communication.

Read more