See comment: this is only a difference between how Windows and Linux handle GET requests.
Running a BDS server on Linux Ubuntu 20.04.6 LTS, utilizing the gametest @minecraft/server-net.HttpRequest method, and noticing that headers and request payloads are not sent from BDS on Linux while they are sent from BDS on Windows. Both client and server code is the same, and I can confirm that requests are reaching the server from the BDS client on both platforms.
Running netcat on Linux shows the following:
GET /write_state HTTP/1.1
Host: 127.0.0.1:8888
Accept: */*
User-Agent: libhttpclient/1.0.0.0
While running ncat on Windows shows the following:
GET /update HTTP/1.1
Connection: Keep-Alive
User-Agent: libhttpclient/1.0.0.0
Content-Length: 53
Host: 127.0.0.1:8888
{"time":5000,"weather":0,"entities":{},"messages":[]}
Note the content length header and the payload (both requests should have a payload).
Code sample:
const req = new mcnet.HttpRequest(HOST + endpoint);
req.setTimeout(0.5);
if (body !== undefined) req.setBody(body);
if (headers !== undefined) {
const headerObjs: mcnet.HttpHeader[] = [];
for (const [k, v] of Object.entries(headers)) {
headerObjs.push(new mcnet.HttpHeader(k, v));
}
req.setHeaders(headerObjs);
}
let res;
try {
res = await mcnet.http.request(req);
} catch(e) {
console.error('Invalid request: ', e);
return;
}
Let me know if there is anything that would help narrow this down. Thanks!
Comments 3
Hi
Does this issue still occur after updating to 1.20.15?
This ticket will automatically reopen when you reply.
Cleaning up old tickets: This ticket had been set to 'Awaiting Response', but has not received a response from the reporter (~3 months+) so is being closed as Incomplete. If you feel this is still a valid issue then please comment, or create a new ticket following the Issue Guidelines which includes steps to reproduce the problem.
Quick Links:
📓 Issue Guidelines – 💬 Mojang Support – 📧 Suggestions – 📖 Minecraft Wiki
Updated title to reflect the more accurate case: this is only a difference on GET requests on Linux vs Windows.
Test Code used:
Post, Delete, and Put all behaved identically.
Response (Windows) (note the data field with "Test test test"):
Response Linux (note the empty data field):
Expected behavior here is that the two platforms should operate the same, either both allowing GET requests to have attached bodies, or for neither to allow bodies and to explicitly throw an exception when set.