Author: remi
Date: 2009-02-17 08:35:58 +0100 (Tue, 17 Feb 2009)
New Revision: 3653

Modified:
   
software_suite_v2/software/gadgets/tuxdroid-gadget-weather/trunk/tuxdroid-gadget-weather/sources/net/karmaLab/tuxDroid/gadgets/WeatherGadget.java
Log:
* fixed the HTTP request (hacked the "UserAgent" header tag) to retrieve the 
weather forecast from google

Modified: 
software_suite_v2/software/gadgets/tuxdroid-gadget-weather/trunk/tuxdroid-gadget-weather/sources/net/karmaLab/tuxDroid/gadgets/WeatherGadget.java
===================================================================
--- 
software_suite_v2/software/gadgets/tuxdroid-gadget-weather/trunk/tuxdroid-gadget-weather/sources/net/karmaLab/tuxDroid/gadgets/WeatherGadget.java
   2009-02-17 01:25:27 UTC (rev 3652)
+++ 
software_suite_v2/software/gadgets/tuxdroid-gadget-weather/trunk/tuxdroid-gadget-weather/sources/net/karmaLab/tuxDroid/gadgets/WeatherGadget.java
   2009-02-17 07:35:58 UTC (rev 3653)
@@ -32,7 +32,7 @@
 import java.io.OutputStreamWriter;
 import java.io.Writer;
 import java.net.URL;
-import java.net.URLConnection;
+import java.net.HttpURLConnection;
 
 import net.karmaLab.xml.elements.Element;
 import net.karmaLab.xml.parser.XMLParser;
@@ -121,7 +121,10 @@
                        /* create a new URL object */
                        URL xml = new 
URL(String.format(configuration().getGoogleURL(), 
configuration().getLocation()));
                        /* Open the connection */
-                       URLConnection yc = xml.openConnection();
+            HttpURLConnection.setDefaultRequestProperty("User-Agent", 
"Mozilla/4.0  ( compatible ) ");
+            HttpURLConnection yc = (HttpURLConnection) xml.openConnection();
+            yc.setRequestProperty ("User-Agent", "Mozilla/4.0  ( compatible ) 
");
+
                        /* And read the stream input */
                        BufferedReader streamInput = new BufferedReader(new 
InputStreamReader(yc.getInputStream()));
 


------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
_______________________________________________
Tux-droid-svn mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tux-droid-svn

Reply via email to