1
0
mirror of https://github.com/SquidDev-CC/CC-Tweaked synced 2024-12-25 17:40:30 +00:00

Pass follow_redirects flag to the CORS proxy

Currently redirects would be returned from the proxy, and then
immediately followed by XMLHTTPRequest. The proxy now follows requests
(when requested), so that should no longer happen.

We should probably switch over to fetch(...) here, to allow setting
follow_redirects to false, but that's a job for another day.

Haha, so many web emulator related commits of late. This'll die down
soon.
This commit is contained in:
Jonathan Coates 2023-10-08 20:12:47 +01:00
parent 3ebdf7ef5e
commit 27dc8b5b2c
No known key found for this signature in database
GPG Key ID: B9E431FF07C98D06

View File

@ -47,6 +47,7 @@ public class THttpRequest extends Resource<THttpRequest> {
private final @Nullable String postBuffer;
private final HttpHeaders headers;
private final boolean binary;
private final boolean followRedirects;
public THttpRequest(
ResourceGroup<THttpRequest> limiter, IAPIEnvironment environment, String address, @Nullable String postText,
@ -58,6 +59,7 @@ public class THttpRequest extends Resource<THttpRequest> {
postBuffer = postText;
this.headers = headers;
this.binary = binary;
this.followRedirects = followRedirects;
if (postText != null) {
if (!headers.contains(HttpHeaderNames.CONTENT_TYPE)) {
@ -102,6 +104,7 @@ public class THttpRequest extends Resource<THttpRequest> {
var header = iterator.next();
request.setRequestHeader(header.getKey(), header.getValue());
}
request.setRequestHeader("X-CC-Redirect", followRedirects ? "true" : "false");
request.send(postBuffer);
checkClosed();
} catch (Exception e) {