Page MenuHomeFeedback Tracker

1.26.159040: RestApi reports error code 8 when HTTP server returns empty body
Awaiting internal Testing, NormalPublic

Description

When using RestApi to make HTTP requests, if the remote end returns an empty (Content-Length: 0) body, the RestCallback instance has its OnError method called with error code 8 (EREST_ERROR_APPERROR).

It does not matter if the HTTP server returns status 204 "No Content" or 200 "OK". In either case, DayZ reports error code 8.

An empty response body is a valid server response and should not be reported as an error when the HTTP status code is in the 200-299 range.

Note: I've only tested this with POST requests.

Details

Severity
Minor
Resolution
Open
Reproducibility
Always
Operating System
Windows 10 x64
Category
General
Steps To Reproduce

Example DayZ script:

class MyCallback : RestCallback
{
    override void OnError(int errorCode)
    {
        PrintFormat("ERROR :: code %1", errorCode);
    }
};

// ...

auto data = new JsonObject();
data.AddString("content", "this is my content");

auto cbx = new MyCallback();
auto ctx = GetRestApi().GetRestContext("http://localhost:8000/endpoint");
ctx.SetHeader("application/json");
ctx.POST(cbx, "", data.GetJson());

Example Python-based HTTP server code (requires tornado):

import asyncio
from pprint import pformat
from tornado.web import Application, RequestHandler


class WebhookHandler(RequestHandler):
    def post(self):
        print("Request received:")
        print(f"  URL: {self.request.uri}")
        print(f"  Headers:\n{pformat(dict(self.request.headers), indent=5)}")
        print(f"  Body: {self.request.body}")

        # self.set_status(204)  # uncomment to test 204 instead of 200 status code

async def main():
    app = Application([
        (r"/.*", WebhookHandler)
    ])
    app.listen(8000)
    await asyncio.Event().wait()


if __name__ == "__main__":
    asyncio.run(main())

Event Timeline

tjensen created this task.Wed, Nov 27, 5:54 PM
Geez changed the task status from New to Awaiting internal Testing.Thu, Nov 28, 11:41 AM