Chris Angelico <ros...@gmail.com>: > On Sat, Dec 1, 2018 at 10:16 PM Marko Rauhamaa <ma...@pacujo.net> wrote: >> and the framing format is HTTP. I will need to type something like this: >> >> POST / HTTP/1.1^M >> Host: localhost^M >> Content-type: application/json^M >> Content-length: 54^M >> ^M >> { >> "msgtype": "echo-req", >> "opid": 3487547843 >> } >> >> That's almost impossible to type without a syntax error. > > 1) Set your Enter key to send CR-LF, at least for this operation. > That's half your problem solved.
That can be much harder than typing ctrl-SPC. It *is* supported by netcat, for example, but then you have to carefully recompute the content-length field. > 2) Send the request like this: > > POST / HTTP/1.0 > Content-type: application/json > > {"msgtype": "echo-req", "opid": 3487547843} > > Then shut down your end of the connection, probably with Ctrl-D. I'm > fairly sure I can type that without bugs, and any compliant HTTP > server should be fine with it. If I terminated the input, I wouldn't need any framing. The point is to carry a number of JSON messages/documents over a single bytestream or in a single file. That means the HTTP content-length would be mandatory. Marko -- https://mail.python.org/mailman/listinfo/python-list