Skip to content

[.NET-SDK] Content-Length wird falsch berechnet und Versand bricht ab

Description of the bug:

Beim Versand einer Submission über das FIT-Connect .NET SDK v3.0.0 schlägt der HTTP-Request fehl, wenn JSON-Daten aus einer Datei geladen und anschließend durch das SDK weiterverarbeitet werden. Der Fehler tritt auf, weil das SDK die Content-Length mit der Zeichenlänge (body.Length) berechnet, während der tatsächliche HTTP-Body mehr Bytes enthält.

Dies führt dazu, dass .NET den Versand abbricht, sobald mehr Bytes in den Request-Stream geschrieben werden sollen, als in Content-Length angegeben sind.

  1. JSON-Datei im Anhang verwenden
  2. Datei einlesen und an SetJsonData() übergeben
  3. Submission versenden
  4. Versand schlägt fehl mit HttpRequestException: content would exceed Content-Length

Current behavior:

Beim Senden entsteht folgende Exception: HttpRequestException: Unable to write content to request stream; content would exceed Content-Length.

Expected behavior:

  • Content-Length sollte Byte-genau berechnet werden

oder

  • der Header sollte nicht gesetzt werden (Chunked Transfer Encoding).

Environments:

TEST, STAGE, PROD (.NET-SDK 3.0.0)

Additional Information:

Problemstelle in FitConnect.Helper.RestCallService.cs: request.Content.Headers.ContentLength = body.Length;

Dependency / relationship to other issues:

Responsible person / team:

Transfer history to different teams

Contact persons including contact details:

Screenshots / Logs / Requests:

Logauszug: Body: {"callback":null,"publicService":{"name":"Anerkennung Lehramtsprüfung NRW", ...} HttpRequestException: Unable to write content to request stream; content would exceed Content-Length.

Byte-Vergleich: JSON LENGTH: 692 FILE BYTE LENGTH: 694

Code_mit_Beispieldatei.zip

Checklist:

  • Add Severity label
  • Add team label
  • Related/affected issues/stories/epics linked and explained in the bug issue
  • Creation of an automated test
  • Bugfix deployed on DEV
  • Bugfix tested on DEV
  • Bugfix deployed on TEST
  • Bugfix tested on TEST (possibly also by the connection project itself)
  • Successful fix reported to Team Operations (Teams channel)
  • Bugfix deployed on STAGE
  • Bugfix tested on STAGE if necessary
  • Bugfix deployed on PROD
  • Bugfix tested on PROD (possibly also by the connection project itself)
  • Final communication by Team Operations if necessary
  • Internal documentation was checked and updated if necessary
  • External documentation has been checked and updated if necessary
  • Updated changelog if necessary

Approach/Solution:

Release version of the artifact:

Edited by Fabian Braun