This project is read-only.


POST Request without Content-Type header gives NullReferenceException


a POST request without a Content-Type results in NullReferenceException exception.
client code:
Public Function WebPost(url As String, content As String) As String
    Using wc As New WebClient()
        wc.Proxy = Nothing
        Return (wc.UploadString(New Uri(url), "POST", content))
    End Using
End Function
if one adds a Content-Type: e.g.: wc.Headers("Content-Type") = "application/mine"
then it works.

Server Exception Stack Trace

System.NullReferenceException: Object reference not set to an instance of an object.
at HttpServer.BodyDecoders.BodyDecoderCollection.Decode(Stream stream, ContentTypeHeader contentType, Encoding encoding) in C:\Smart_Elite\\HttpServer\BodyDecoders\BodyDecoderCollection.cs:line 51
at HttpServer.Server.DecodeBody(IRequest request) in C:\Smart_Elite\\HttpServer\Server.cs:line 164
at HttpServer.Server.HandleRequest(RequestEventArgs e) in C:\Smart_Elite\\HttpServer\Server.cs:line 229
at HttpServer.Server.OnRequest(Object sender, RequestEventArgs e) in C:\Smart_Elite\\HttpServer\Server.cs:line 302
the attached patch just adds a check for contentType being null.

file attachments

Closed Jan 31, 2012 at 5:51 AM by jgauffin


angelblaze wrote Oct 3, 2011 at 3:03 PM

Forget to mention this is against v2, latest SVN.

wrote Jan 31, 2012 at 5:51 AM

wrote Feb 22, 2013 at 12:29 AM

wrote May 16, 2013 at 12:01 PM