httprequest - (partial) HTTP Request isn't recognized by C# HTTP Server -
httprequest - (partial) HTTP Request isn't recognized by C# HTTP Server -
in visual studio 13 console application, receive next byte stream on tcp-socket(receiving embedded device):
post /setup http/1.1 content-length: 6 content-type: application/setup+tlv8 tlv8-data
although seem valid http request, none of next attempts have successful been recognize http request: (on regular http requests work perfectly)
.net httplistener class (does not inform me request has been invoked) grapevine (same thing, routes given on post or get) https://github.com/scottoffen/grapevine alchemy (onconnect method has been invoked, in according usercontext seeing request path: / . similar reported issue: https://github.com/olivine-labs/alchemy-websockets/issues/70so far, i'm interested in requested path post or attached content (tlv formatted) body.
am wrong in configuring? such as: need tell proper content-type ? there way rid of writing own simple text parser ?
code sample in case of grapevine:
private void init() { s = new pairserver(); s.host = "172.28.22.78"; s.port = "52025"; s.start(); }
providing next server class:
public class pairserver : restserver { [restroute(method = httpmethod.post, pathinfo = @"^/setup")] [restroute(method = httpmethod.get, pathinfo = @"^/setup")] public void pairsetup(httplistenercontext context) { // not reach here } [restroute(method = httpmethod.post)] public void anyroute(httplistenercontext context) { // not here }
although seem valid http request
no, that's not valid http request. valid http request, specification
states, must include host
request header:
a client must include host header field in http/1.1 request messages . if requested uri not include net host name service beingness requested, host header field must given empty value. http/1.1 proxy must ensure request message forwards contain appropriate host header field identifies service beingness requested proxy. internet-based http/1.1 servers must respond 400 (bad request) status code http/1.1 request message lacks host header field.
so create sure client next specification:
post /setup http/1.1 host: example.com content-length: 6 content-type: application/setup+tlv8 tlv8-data
c# httprequest httplistener http-post
Comments
Post a Comment