mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2024-12-26 01:50:29 +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:
parent
3ebdf7ef5e
commit
27dc8b5b2c
@ -47,6 +47,7 @@ public class THttpRequest extends Resource<THttpRequest> {
|
|||||||
private final @Nullable String postBuffer;
|
private final @Nullable String postBuffer;
|
||||||
private final HttpHeaders headers;
|
private final HttpHeaders headers;
|
||||||
private final boolean binary;
|
private final boolean binary;
|
||||||
|
private final boolean followRedirects;
|
||||||
|
|
||||||
public THttpRequest(
|
public THttpRequest(
|
||||||
ResourceGroup<THttpRequest> limiter, IAPIEnvironment environment, String address, @Nullable String postText,
|
ResourceGroup<THttpRequest> limiter, IAPIEnvironment environment, String address, @Nullable String postText,
|
||||||
@ -58,6 +59,7 @@ public class THttpRequest extends Resource<THttpRequest> {
|
|||||||
postBuffer = postText;
|
postBuffer = postText;
|
||||||
this.headers = headers;
|
this.headers = headers;
|
||||||
this.binary = binary;
|
this.binary = binary;
|
||||||
|
this.followRedirects = followRedirects;
|
||||||
|
|
||||||
if (postText != null) {
|
if (postText != null) {
|
||||||
if (!headers.contains(HttpHeaderNames.CONTENT_TYPE)) {
|
if (!headers.contains(HttpHeaderNames.CONTENT_TYPE)) {
|
||||||
@ -102,6 +104,7 @@ public class THttpRequest extends Resource<THttpRequest> {
|
|||||||
var header = iterator.next();
|
var header = iterator.next();
|
||||||
request.setRequestHeader(header.getKey(), header.getValue());
|
request.setRequestHeader(header.getKey(), header.getValue());
|
||||||
}
|
}
|
||||||
|
request.setRequestHeader("X-CC-Redirect", followRedirects ? "true" : "false");
|
||||||
request.send(postBuffer);
|
request.send(postBuffer);
|
||||||
checkClosed();
|
checkClosed();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
Loading…
Reference in New Issue
Block a user