Official websites use .gov
A .gov website belongs to an official government organization in the United States.

Secure .gov websites use HTTPS
A lock ( ) or https:// means you've safely connected to the .gov website. Share sensitive information only on official, secure websites.




::: content [;{.source}]{.comments} {.source}[; NOSA HEADER START{.source}]{.comments} {.source}[;{.source}]{.comments} {.source}[; The contents of this file are subject to the terms of the NASA Open {.source}]{.comments} {.source}[; Source Agreement (NOSA), Version 1.3 only (the "Agreement"). You may {.source}]{.comments} {.source}[; not use this file except in compliance with the Agreement.{.source}]{.comments} {.source}[;{.source}]{.comments} {.source}[; You can obtain a copy of the agreement at{.source}]{.comments} {.source}[; docs/NASA_Open_Source_Agreement_1.3.txt{.source}]{.comments} {.source}[; or {.source}]{.comments} {.source}[; https://sscweb.gsfc.nasa.gov/WebServices/NASA_Open_Source_Agreement_1.3.txt.{.source}]{.comments} {.source}[;{.source}]{.comments} {.source}[; See the Agreement for the specific language governing permissions{.source}]{.comments} {.source}[; and limitations under the Agreement.{.source}]{.comments} {.source}[;{.source}]{.comments} {.source}[; When distributing Covered Code, include this NOSA HEADER in each{.source}]{.comments} {.source}[; file and include the Agreement file at {.source}]{.comments} {.source}[; docs/NASA_Open_Source_Agreement_1.3.txt. If applicable, add the {.source}]{.comments} {.source}[; following below this NOSA HEADER, with the fields enclosed by {.source}]{.comments} {.source}[; brackets "[]" replaced with your own identifying information: {.source}]{.comments} {.source}[; Portions Copyright [yyyy] [name of copyright owner]{.source}]{.comments} {.source}[;{.source}]{.comments} {.source}[; NOSA HEADER END{.source}]{.comments} {.source}[;{.source}]{.comments} {.source}[; Copyright (c) 2010-2021 United States Government as represented by the {.source}]{.comments} {.source}[; National Aeronautics and Space Administration. No copyright is claimed {.source}]{.comments} {.source}[; in the United States under Title 17, U.S.Code. All Other Rights Reserved.{.source}]{.comments} {.source}[;{.source}]{.comments} {.source}[;{.source}]{.comments} {.source}[;+{.source}]{.comments} {.source}[; This class represents an object that is used to report HTTP errors.<br>{.source}]{.comments} {.source}[;{.source}]{.comments} {.source}[; Notes:{.source}]{.comments} {.source}[; <ol>{.source}]{.comments} {.source}[; <li>This class exists in both the CDAS and SSC web service IDL{.source}]{.comments} {.source}[; libraries. They should be kept identical to void incompatiblities{.source}]{.comments} {.source}[; for clients that use both libraries simultaneously.</li>{.source}]{.comments} {.source}[; <li>As of release 1.7.35 of the CDAS library the retryAfterTime field{.source}]{.comments} {.source}[; and associated logic is obsolete. The SpdfRest class now handles{.source}]{.comments} {.source}[; a 429/503 http response with a Retry-After header itself and never {.source}]{.comments} {.source}[; calls this class for those responses. The code here has not yet been{.source}]{.comments} {.source}[; deleted because of note 1 above.</li>{.source}]{.comments} {.source}[; </ol>{.source}]{.comments} {.source}[;{.source}]{.comments} {.source}[; @copyright Copyright (c) 2010-2021 United States Government as represented{.source}]{.comments} {.source}[; by the National Aeronautics and Space Administration. No{.source}]{.comments} {.source}[; copyright is claimed in the United States under Title 17,{.source}]{.comments} {.source}[; U.S.Code. All Other Rights Reserved.{.source}]{.comments} {.source}[;{.source}]{.comments} {.source}[; @author B. Harris{.source}]{.comments} {.source}[;-{.source}]{.comments} {.source}[;+{.source}]{.comments} {.source}[; Creates an SpdfHttpErrorReporter object.{.source}]{.comments} {.source}[;{.source}]{.comments} {.source}[; @returns reference to an SpdfHttpErrorReporter object.{.source}]{.comments} {.source}[;-{.source}]{.comments} {.source}[]{#SpdfHttpErrorReporter::init:source}function SpdfHttpErrorReporter::init compile_opt idl2 return, self end {.source}[;+{.source}]{.comments} {.source}[; Performs cleanup operations when this object is destroyed.{.source}]{.comments} {.source}[;-{.source}]{.comments} {.source}[]{#SpdfHttpErrorReporter::cleanup:source}pro SpdfHttpErrorReporter::cleanup compile_opt idl2 end {.source}[;+{.source}]{.comments} {.source}[; This procedure is called when an HTTP error occurs. This default{.source}]{.comments} {.source}[; implementation merely prints some diagnostic information.{.source}]{.comments} {.source}[;{.source}]{.comments} {.source}[; @param responseCode {in} {type=int}{.source}]{.comments} {.source}[; the HTTP response code of the request causing the error.{.source}]{.comments} {.source}[; @param responseHeader {in} {type=string}{.source}]{.comments} {.source}[; the HTTP response header of the request causing the error.{.source}]{.comments} {.source}[; @param responseFilename {in} {type=string}{.source}]{.comments} {.source}[; the name of an error response file sent when the error{.source}]{.comments} {.source}[; occurred.{.source}]{.comments} {.source}[;-{.source}]{.comments} {.source}[]{#SpdfHttpErrorReporter::reportError:source}pro SpdfHttpErrorReporter::reportError, $ responseCode, responseHeader, responseFilename compile_opt idl2 case responseCode of 429 || 503: begin print, 'An HTTP 429/503 error has occurred.' {.source}[;{.source}]{.comments} {.source}[; Currently, SSC/CDAS never sends a date/time string (only {.source}]{.comments} {.source}[; number of seconds to wait) in the Retry-After header. If {.source}]{.comments} {.source}[; it ever starts, then the following code will have to be {.source}]{.comments} {.source}[; updated to handle that.{.source}]{.comments} {.source}[;{.source}]{.comments}retryAfter = stregex(responseHeader, $ 'Retry-After: ([0-9]+)' + string(13b), $ /extract, /subexpr) if n_elements(retryAfter) eq 2 && $ strlen(retryAfter[1]) gt 0 then begin self.retryAfterTime = systime(/seconds) + fix(retryAfter[1]) endif end else: begin print, 'An HTTP error has occurred.' print, !error_state.msg print, 'HTTP response code = ', responseCode print, 'HTTP response header = ', responseHeader if n_elements(responseFilename) ne 0 then begin print, 'HTTP response filename = ', responseFilename self->printResponse, responseFilename endif end endcase end{.source}[;+{.source}]{.comments} {.source}[; This procedure prints some diagnostic information from the given{.source}]{.comments} {.source}[; HTTP error response file. It only recognizes the "typical" error{.source}]{.comments} {.source}[; response from the web services.{.source}]{.comments} {.source}[;{.source}]{.comments} {.source}[; @param responseFilename {in} {type=string}{.source}]{.comments} {.source}[; the name of an error response file sent when the error{.source}]{.comments} {.source}[; occurred.{.source}]{.comments} {.source}[;-{.source}]{.comments} {.source}[]{#SpdfHttpErrorReporter::printResponse:source}pro SpdfHttpErrorReporter::printResponse, $ responseFilename compile_opt idl2 if strlen(responseFilename) eq 0 then return print, 'HTTP Error Response' response = obj_new('IDLffXMLDOMDocument', filename=responseFilename) pElements = response->getElementsByTagName('p') for i = 0, pElements->getLength() - 1 do begin pNode = pElements->item(i) pAttributes = pNode->getAttributes() pClassAttribute = pAttributes->getNamedItem('class') if obj_valid(pClassAttribute) then begin pClassValue = pClassAttribute->getNodeValue() pLastChild = pNode->getLastChild() if obj_valid(pLastChild) then begin pLastChildValue = pLastChild->getNodeValue() print, pClassValue, ': ', pLastChildValue endif else begin print, pClassValue endelse endif endfor obj_destroy, response end {.source}[;+{.source}]{.comments} {.source}[; Suspends execution until after any retryAfterTime. If there has been{.source}]{.comments} {.source}[; no HTTP 429/503/RetryAfter condition or the current time is after the{.source}]{.comments} {.source}[; retryAfterTime, then no suspension occurs.{.source}]{.comments} {.source}[;-{.source}]{.comments} {.source}[]{#SpdfHttpErrorReporter::waitUntilRetryAfterTime:source}pro SpdfHttpErrorReporter::waitUntilRetryAfterTime compile_opt idl2 waitTime = self.retryAfterTime - systime(/seconds) if waitTime gt 0.0 then wait, waitTime end {.source}[;+{.source}]{.comments} {.source}[; Gets the retryAfterTime value.{.source}]{.comments} {.source}[;{.source}]{.comments} {.source}[; @returns the number of seconds elapsed since 1970-01-01 when we can{.source}]{.comments} {.source}[; retry a request following an HTTP response with status 429/503{.source}]{.comments} {.source}[; and an HTTP Retry-After header value.{.source}]{.comments} {.source}[;-{.source}]{.comments} {.source}[]{#SpdfHttpErrorReporter::getRetryAfterTime:source}function SpdfHttpErrorReporter::getRetryAfterTime compile_opt idl2 return, self.retryAfterTime end {.source}[;+{.source}]{.comments} {.source}[; Defines the SpdfHttpErrorReporter class.{.source}]{.comments} {.source}[;{.source}]{.comments} {.source}[; @field retryAfterTime number of seconds elapsed since 1970-01-01 when{.source}]{.comments} {.source}[; we can retry a request following an HTTP response with status 429/503{.source}]{.comments} {.source}[; and an HTTP Retry-After header value.{.source}]{.comments} {.source}[;-{.source}]{.comments} {.source}[]{#SpdfHttpErrorReporter__define:source}pro SpdfHttpErrorReporter__define compile_opt idl2 struct = { SpdfHttpErrorReporter, $ retryAfterTime:0.0d $ } end {.source} :::