Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updates SpiceClient to handle redirect requests #5696

Merged
merged 1 commit into from
Jan 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
34 changes: 12 additions & 22 deletions isis/src/base/apps/spiceinit/SpiceClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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();
Expand Down Expand Up @@ -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
Expand Down
Loading