Describe the bug
When I try to send any of POST, PUT, DELETE requests using server-net, if I do not include a request body, the game crashes. I believe the game loop gets blocked since entities stop moving, blocks stop dropping themselves when mined, and I can't even send commands via the console.
To Reproduce
Steps to reproduce the behavior:
Create a script that sends a DELETE request to an API endpoint
Do not include a request body
Notice how entities stop moving
Also, notice on your API access logs that the request never came in
Expected behavior
DELETE request gets sent to the API and you don't crash your server
Screenshots
Console logs. Sends the requests. Notice how there is no response.
Changed the script code to include an empty JSON body. Notice the response.
Additional context
Simple code that accesses all 4 methods on an endpoint in the API and returns the response body.
Technically, DELETE requests shouldn't even have a request body so I never set one, and was so confused why it would crash.
import { http, HttpHeader, HttpRequest, HttpRequestMethod } from '@minecraft/server-net';
system.run(() => {
const requests = [
new HttpRequest(`http://nexuscore:8000/api/v0.1/users/test`).setMethod(HttpRequestMethod.Get),
new HttpRequest(`http://nexuscore:8000/api/v0.1/users/test`).setMethod(HttpRequestMethod.Put),
new HttpRequest(`http://nexuscore:8000/api/v0.1/users/test`).setMethod(HttpRequestMethod.Post),
new HttpRequest(`http://nexuscore:8000/api/v0.1/users/test`).setMethod(HttpRequestMethod.Delete),
]
for (const request of requests) {
request.body = JSON.stringify({}) // If you do not include this line, POST, PUT and DELETE requests crash the game
request.headers = [
new HttpHeader("Content-Type", "application/json"),
new HttpHeader("auth", "my-auth-token"),
];
console.log(request.uri, request.method)
http.request(request).then((response) => console.log(response.body))
}
})
Describe the bug When I try to send any of POST, PUT, DELETE requests using
server-net
, if I do not include a request body, the game crashes. I believe the game loop gets blocked since entities stop moving, blocks stop dropping themselves when mined, and I can't even send commands via the console.To Reproduce Steps to reproduce the behavior:
DELETE
request to an API endpointExpected behavior DELETE request gets sent to the API and you don't crash your server
Screenshots Console logs. Sends the requests. Notice how there is no response.
Changed the script code to include an empty JSON body. Notice the response.
Additional context Simple code that accesses all 4 methods on an endpoint in the API and returns the response body. Technically, DELETE requests shouldn't even have a request body so I never set one, and was so confused why it would crash.