B4J Question Trying to emulate an http 1.1 server response.

hatzisn

Well-Known Member
Licensed User
Longtime User
I would like to emulate an http 1.1 server response. The intention is to send data in a JSON with a single http request from a .NET app. I am able to receive the request headers and the content with ServerSocket but then immediately the connection is terminated and I cannot send the response. Anyone can help with this?

Thanks
 

hatzisn

Well-Known Member
Licensed User
Longtime User
Thank you for the response. The problem was that I used previously used code and I was adding a suffix for my protocol purposes in the previous code... I am reporting this in case someone else does the same mistake. Here is the HTTP 1.1 response I was using unsuccesfully due to the added suffix. Without the suffix it works. SendData performs an asyncstream.Write("...") .
B4X:
SendData($"HTTP/1.1 200 OK${Chr(13) & Chr(10)}Content-Type: text/html; charset=utf-8${Chr(13) & Chr(10)}Content-Length: 2${Chr(13) & Chr(10)}${Chr(13) & Chr(10)}Ok"$)
 
Last edited:
Upvote 0
Top