Wolfram|Alpha is HTTPS-only: make the fetch command configurable, fix two changed error formats - #1
Open
SpitfireTN wants to merge 1 commit into
Open
Conversation
api.wolframalpha.com has answered port 80 with a 308 redirect to https for
some time now. C:http_get (Aminet, 2015) speaks plain HTTP only and does not
follow redirects, so Guru as released can no longer reach the API at all.
Make the transport configurable rather than hardcoding one fetch command:
g.fetchCmd "httpget" (AmiSSL 5, native TLS on the Amiga) or "http_get"
g.apiBase the API root, so http_get users can point at a proxy that
performs the TLS leg for them
http_get takes a -u user-agent and AmiSSL's httpget takes the URL alone, so
fetchWebRequest builds the command accordingly. The startup existence check
and its error message now follow g.fetchCmd instead of naming http_get.
Also handle two response-format changes that stopped Guru's own error
handling from matching:
- An invalid AppId now returns a bare "Invalid appid" rather than
"Error 1: Invalid appid", so a bad key fell through to be displayed as an
answer instead of raising the AppId error.
- 501 bodies now arrive wrapped in double quotes, e.g.
"Wolfram|Alpha did not understand your input". The == comparisons missed,
so Guru printed the error as a genuine answer with the footer attached.
Unwrapping is applied only when the unwrapped text is one of the known
error strings, so a real answer that happens to be a quotation is untouched.
Verified against the live API: both formats confirmed, and the unwrap logic
tested over quoted errors, a bare invalid-appid, a quoted genuine answer and a
plain answer.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hello — thanks for Guru, it has been running on Reign of Fire BBS for a while.
It stopped working, and the cause turns out to affect every install rather than
just mine, so I thought it was worth offering back.
The problem
api.wolframalpha.comnow answers port 80 with a308redirect tohttps://:C:http_get(Aminet, 2015) speaks plain HTTP only and does not followredirects — there is no
ssl/tls/locationstring in the binary — so Gurucan no longer reach the API at all. Every
/v1/*and/v2/*endpoint behavesthe same way, so there is no plain-HTTP path left to fall back to.
What this changes
The fetch command and API root are now configurable instead of hardcoded:
AmiSSL 5 ships a ready-built 68k
httpgetinDeveloper/Examples/AmigaOS3/that uses
OSSL_HTTP_get()— no libcurl needed, and it takes a URL much likehttp_getdid. That keeps everything on the Amiga.For anyone who would rather keep
http_get, pointingg.apiBaseat aplain-HTTP proxy that performs the TLS leg also works.
http_gettakes-u, AmiSSL'shttpgettakes the URL alone, sofetchWebRequestbuilds whichever form applies. The startup existence checkand its error message follow
g.fetchCmdtoo — otherwise a correct AmiSSLinstall gets rejected at launch.
Two response formats also changed
Both stopped Guru's own error handling from matching:
Invalid appid, notError 1: Invalid appid. A bad key fell through and was displayed as if itwere an answer instead of reaching
badAppId.501bodies now arrive quote-wrapped:"Wolfram|Alpha did not understand your input". The==tests missed, sothe error printed as a genuine answer with the "powered by Wolfram|Alpha"
footer attached.
The unwrapping is deliberately narrow — it only applies when the unwrapped
text matches one of the known error strings, so a real answer that happens to
be a quotation is left alone. It also sits ahead of your
noShortAnswer -> sorryDavestep, so a quoted "No short answer available"now reaches it correctly.
Verification, and its limits
Both response formats confirmed against the live API. The error-handling
logic was tested over quoted errors, bare and old-style invalid-appid, a
quoted genuine answer and a plain answer — 8/8, including the interaction with
sorryDave.Not yet run on real hardware against AmiSSL
httpget. My board runs underAmiberry with
bsdsocket_emu, and whether AmiSSL's TLS works over emulatedsockets is still an open question on my end. The transport indirection and the
error-string fixes are independent of that, but I did not want to claim an
end-to-end pass I have not seen. Happy to report back once I have.
No configuration of mine is included;
g.appIdremainsyourappidhere.