summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormonsta <[email protected]>2016-08-29 07:45:16 +0300
committermonsta <[email protected]>2016-08-29 13:56:31 +0300
commita752b9237fc1014f9e9f1897b9cc3ec4c79cc44b (patch)
tree8e425243439a29052ddcaa94060d7a7a2cd88dda
parent140f7f954e35caf91ab92f94a8a5fe6c49214be3 (diff)
downloadlibmateweather-a752b9237fc1014f9e9f1897b9cc3ec4c79cc44b.tar.bz2
libmateweather-a752b9237fc1014f9e9f1897b9cc3ec4c79cc44b.tar.xz
metar: switch to https and use recommended method of data retrieval
as per https://aviationweather.gov/dataserver/bestpractices patch by Frank Dana: https://git.gnome.org/browse/libgweather/commit/?id=283afc2d23355def1c1bab70a641f40cea52ba7f
-rw-r--r--libmateweather/weather-metar.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/libmateweather/weather-metar.c b/libmateweather/weather-metar.c
index 0787546..5bcabc3 100644
--- a/libmateweather/weather-metar.c
+++ b/libmateweather/weather-metar.c
@@ -510,7 +510,7 @@ metar_finish (SoupSession *session, SoupMessage *msg, gpointer data)
loc = info->location;
- searchkey = g_strdup_printf ("\n%s", loc->code);
+ searchkey = g_strdup_printf ("<raw_text>%s", loc->code);
p = strstr (msg->response_body->data, searchkey);
g_free (searchkey);
if (p) {
@@ -522,8 +522,8 @@ metar_finish (SoupSession *session, SoupMessage *msg, gpointer data)
metar = g_strdup (p);
success = metar_parse (metar, info);
g_free (metar);
- } else if (!strstr (msg->response_body->data, "AVIATION WEATHER CENTER")) {
- /* The response doesn't even seem to have come from NWS...
+ } else if (!strstr (msg->response_body->data, "aviationweather.gov")) {
+ /* The response doesn't even seem to have come from NOAA...
* most likely it is a wifi hotspot login page. Call that a
* network error.
*/
@@ -550,8 +550,14 @@ metar_start_open (WeatherInfo *info)
}
msg = soup_form_request_new (
- "GET", "http://aviationweather.gov/metar/data",
- "ids", loc->code,
+ "GET", "https://www.aviationweather.gov/adds/dataserver_current/httpparam",
+ "dataSource", "metars",
+ "requestType", "retrieve",
+ "format", "xml",
+ "hoursBeforeNow", "3",
+ "mostRecent", "true",
+ "fields", "raw_text",
+ "stationString", loc->code,
NULL);
soup_session_queue_message (info->session, msg, metar_finish, info);