Unverified Commit e46b6e20 authored by Amy Stamile's avatar Amy Stamile Committed by GitHub
Browse files

Updates SpiceClient to handle redirect requests (#5696)

parent 09cba88a
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -41,6 +41,7 @@ release.

### Fixed
- Fixed kaguyatc2isis invalid BandBin values [#5629](https://github.com/DOI-USGS/ISIS3/issues/5629)
- Fixed SpiceClient to handle redirect requests.

## [9.0.0] - 09-25-2024

+12 −22
Original line number Diff line number Diff line
@@ -85,25 +85,6 @@ namespace Isis {

    *p_xml = QString(QByteArray(raw.toLatin1()).toHex().constData());

    /*
     * For Debugging, you may want to run spiceserver locally (without spiceinit).
     *
     * Uncomment the following code and run the spiceinit with web=true. An error will be thrown
     * with the file name of the stored input hex file. You can rsync that file to your work area
     * and run spiceserver locally.
     */

    // const char *inmode = "overwrite";
    // const char *ext  = "dat";
    // TextFile newInput;
    // QString serverInputFile("/tmp/input");
    // newInput.Open(serverInputFile, inmode, ext);
    // newInput.Rewind();//start at begining
    // newInput.PutLine(hexCode);
    // newInput.Close();
    // QString msg = "Exporting expected server input to: " + serverInputFile;
    // throw IException(IException::Programmer, msg, _FILEINFO_);

    int contentLength = p_xml->length();
    QString contentLengthStr = toString((BigInt)contentLength);

@@ -112,9 +93,6 @@ namespace Isis {
    p_request->setRawHeader("User-Agent", "SpiceInit 1.0");
    p_request->setHeader(QNetworkRequest::ContentTypeHeader,
                         "application/x-www-form-urlencoded");
    //p_request->setRawHeader("Content-Length", contentLengthStr.c_str());
    //p_request->setAttribute(QNetworkRequest::DoNotBufferUploadDataAttribute,
    //    true);

    moveToThread(this);
    start();
@@ -179,6 +157,18 @@ namespace Isis {
   * @param reply
   */
  void SpiceClient::replyFinished(QNetworkReply *reply) {
    // Check for redirection
    QVariant redirectionTarget = reply->attribute(QNetworkRequest::RedirectionTargetAttribute);
    if (!redirectionTarget.isNull()) {
        QUrl redirectedUrl = redirectionTarget.toUrl();

        // Update the request with the new URL and re-send
        p_request->setUrl(redirectedUrl);
        sendRequest();
        return;
    }

    // No redirection, proceed with the original processing
    p_rawResponse = new QString(QString(reply->readAll()));

    // Decode the response