StreamWriter.WriteLine write LF line break code on Linux
July 17, 2020•104 words
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.
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