Skip to content

Deserialization fails when Content-Type is null #789

@Tylerflick

Description

@Tylerflick

I recently found a bug where a DELETE response object causes a null reference exception when the response meets the following:

  • content-type: null
  • body: null
  • content-length: 0

This most likely affects all request types.

Looking through the source the issue appears to be line 624 in RestSharp/RestClient.cs where raw.ContentType is being accessed:
if (response.ErrorException == null) { IDeserializer handler = this.GetHandler(raw.ContentType);

There should either be a null check here, or the IRestResponse object raw should be passed into GetHandler() and the null check should be done there.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions