HttpRequest response content-type handling

Currently ORIGAM has the following decision logic of HttpRequest XSLT function and HttpService.SendRequest workflow method:

if (response.ContentType.Equals("text/xml")
else if (response.ContentType.StartsWith("text/"))
else if (response.ContentType.StartsWith("application/json"))
else {
  // result is binary
}

But there are many other response types that are designated as XML or JSON (the two response formats we automatically convert to data). See this for example:

Auto Detection

I think we should support the following content types to autodetect:

  • text/xml → xml
  • application/xml → xml
  • anything ending with +xml → xml
  • anything ending with +json → json

Forcing content-type

We could add a parameter that would enforce a specific “known” content type — xml or json. With it it would be even possible to get the original xml/json data as text.

Shouldn’t be same applied for json in case of content types ending with +json?

I checked and couldn’t find any resources that would describe such a content type. JSON seems to be unified and always described using application/json content type.

https://www.iana.org/assignments/media-types/media-types.xhtml

I updated the topic accordingly.