- NoaaMetarGetRequest(MetarDataHandler* metarDataHandler, const string& stationId ) :
- Request("http://weather.noaa.gov/pub/data/observations/metar/stations/" + stationId + ".TXT"),
- _fromProxy(false),
- _metarDataHandler(metarDataHandler)
- {
- }
-
- virtual string_list requestHeaders() const
- {
- string_list reply;
- reply.push_back("X-TIME");
- return reply;
- }
-
- virtual std::string header(const std::string& name) const
- {
- string reply;
-
- if( name == "X-TIME" ) {
- std::ostringstream buf;
- buf << globals->get_time_params()->get_cur_time();
- reply = buf.str();
- }
-
- return reply;
- }
-
- virtual void responseHeader(const string& key, const string& value)
- {
- if (key == "x-metarproxy") {
- _fromProxy = true;
- }
- }
-
- virtual void gotBodyData(const char* s, int n)
- {
- _metar += string(s, n);
- }
-
- virtual void responseComplete()
- {
- if (responseCode() == 200) {
- _metarDataHandler->handleMetarData( simgear::strutils::simplify(_metar) );
- } else {
- SG_LOG(SG_ENVIRONMENT, SG_WARN, "metar download failed:" << url() << ": reason:" << responseReason());
- }
- }
-
- virtual void failed()
+ NoaaMetarGetRequest( MetarDataHandler* metarDataHandler,
+ const std::string& stationId ):
+ MemoryRequest(NOAA_BASE_URL + stationId + ".TXT"),
+ _metarDataHandler(metarDataHandler)
+ {
+ std::ostringstream buf;
+ buf << globals->get_time_params()->get_cur_time();
+ requestHeader("X-TIME") = buf.str();
+ }
+
+ virtual void onDone()
+ {
+ if( responseCode() != 200 )