StreamWriter.WriteLine write LF line break code on Linux

I face to misterius issue.

OData batch response of multipart/mixed can not be parsed on Linux. It's good on Windows.
https://github.com/iwate/ODataBatchResponseSample/actions/runs/171318359

I check OData source code. And I've found what I think is the cause.

OData batch response write the content using by RawValueWriter. And RawValueWriter use StreamWriter.

https://github.com/OData/odata.net/blob/182964dd4de0d9271d7e749ff3afde898430326c/src/Microsoft.OData.Core/RawValueWriter.cs#L177

StreamWrite use Environment.NewLineConst.
https://source.dot.net/#System.Private.CoreLib/TextWriter.cs,f3a16a4f25483a3f,references

Environment.NewLineConst is LF on Unix
https://source.dot.net/#System.Private.CoreLib/Environment.UnixOrBrowser.cs,5fbfd9f39ec095a7

You know HTTP multipart content is need CRLF. If you create http writer, you should not use what is dependent on the environment like as StreamWriter.


This issue was fixed in https://github.com/OData/odata.net/issues/1842


You'll only receive email when iwate publishes a new post

More fromĀ iwate