[Jwap-info] URL Redirection Header Problem Solution
Brought to you by:
mcdmx,
nikobender
|
From: Domingo M. <dom...@zw...> - 2004-07-08 15:55:51
|
Hi everybody, There is a bug in jWAP related with the redirection information included = in=20 the response header. As you can test with the URL: http://wap.tmovil.cl,=20 which includes redirection, the jWAP classes throw exceptions before you=20 could get the Status response or the rest of the Header information. The problem was found in the class WAPCodePage. The method decodeContentT= ype=20 must include a patch because in the redirection case "contentType =3D NUL= L=20 String". It is also necessary to include a new method called=20 decodeLocation(). With these changes the jWAP can handle redirections bec= ause=20 the Status and the Location fields are reported and there are not excepti= ons.=20 The necessary code inside WAPCodePage is below: ******************************************************* public String decodeContentType(byte[] data) { String retval =3D null; WSPDecoder d =3D new WSPDecoder(data); int o =3D d.getUint8(); //Jose Cavieres: Patch for contentType =3D NULL String =09if(o=3D=3D0){ =09=09retval=3DTransTable.getTable("content-types").code2str(0); =09} //End Patch =09else if( o <=3D 31 ) { // General Form d.seek(-1); long len =3D d.getValueLength(); o =3D d.getUint8(); if( (o & 0x80) !=3D 0 ) { // Short-Integer short wk =3D (short) (o&0x7f); retval =3D TransTable.getTable("content-types").code2str(wk= ); } else if( o <=3D 30 ) { // long-integer d.seek(-1); int wk =3D (int) d.getLongInteger(); retval =3D TransTable.getTable("content-types").code2str(wk= ); } else { // *TEXT EOF d.seek(-1); retval =3D d.getTextString(); } byte[] params =3D d.getBytes(d.getRemainingOctets()); if( params.length > 0 ) { log.warn("decodeContentType: parameter decoding not yet=20 supported"); } } else { // Constrained encoding if( (o & 0x80) !=3D 0 ) { // Short integer short wk =3D (short) (o&0x7f); retval =3D TransTable.getTable("content-types").code2str(wk); } else { // *Text EOF d.seek(-1); retval =3D d.getTextString(); } } return retval; } *************************************************** //Jose Cavieres: new header field "Location", used for redirections public String decodeLocation(byte[] data){ =09WSPDecoder d =3D new WSPDecoder(data); return d.getTextString(); } *************************************************** Please test this changes to check if there are other problems.=20 Thanks to Jose Cavieres, who fixed the bug, for his "decoding" work. Regards, Domingo Morales. |