I noticed that when the response length passes around 1k characters then it is cut at weird lengths: 424, 936 or 1448 characters.
Response is generated correctly but then it is cut so if the body was eg. a JSON then it is malformed.
Any ideas?
Quiet @ Close @ listener; responseBodyLength = 2000; constResponse = ExportString[ GenerateHTTPResponse @ HTTPResponse @ ExportForm[ StringRepeat["a", responseBodyLength], "Text" ] , "HTTPResponse" ]; listener = SocketListen[ Automatic , With[{client = #["SourceSocket"]}, WriteString[client, constResponse]; Close@client] & ]; url = URLBuild[<|"Scheme" -> "http", "Domain" -> First[listener["Socket"]["DestinationIPAddress"]], "Port" -> listener["Socket"]["DestinationPort"]|>]; Test
Table[ StringLength@URLRead[url, "Body"], 50 ] // Counts <|936 -> 13, 1448 -> 35, 424 -> 2|>