From 0607a67a92924703bb5599798cbc24a3e819c0c5 Mon Sep 17 00:00:00 2001 From: ThorstenB Date: Fri, 5 Nov 2010 20:07:50 +0100 Subject: [PATCH] Fixed METAR. Make loader fully HTTP compliant. HTTP protocol requires a "Host:" line. The old noaa server didn't mind. Now it does... --- simgear/environment/metar.cxx | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/simgear/environment/metar.cxx b/simgear/environment/metar.cxx index 3879bb7d..8a06a4cf 100644 --- a/simgear/environment/metar.cxx +++ b/simgear/environment/metar.cxx @@ -190,11 +190,12 @@ char *SGMetar::loadData(const char *id, const string& proxy, const string& port, const int buflen = 512; char buf[2 * buflen]; - string host = proxy.empty() ? "weather.noaa.gov" : proxy; + string metar_server = "weather.noaa.gov"; + string host = proxy.empty() ? metar_server : proxy; string path = "/pub/data/observations/metar/stations/"; path += string(id) + ".TXT"; - _url = "http://weather.noaa.gov" + path; + _url = "http://" + metar_server + path; SGSocket *sock = new SGSocket(host, port.empty() ? "80" : port, "tcp"); sock->set_timeout(10000); @@ -205,10 +206,11 @@ char *SGMetar::loadData(const char *id, const string& proxy, const string& port, string get = "GET "; if (!proxy.empty()) - get += "http://weather.noaa.gov"; + get += "http://" + metar_server; sprintf(buf, "%ld", time); get += path + " HTTP/1.0\015\012X-Time: " + buf + "\015\012"; + get += "Host: " + metar_server + "\015\012"; if (!auth.empty()) get += "Proxy-Authorization: " + auth + "\015\012"; -- 2.39.5