Buy commercial curl support from WolfSSL. We help you work out your issues, debug your libcurl applications, use the API, port to new platforms, add new features and more. With a team lead by the curl founder himself.

Problem setting content-type header when connecting to Microsoft Exchange

From: Jeffrey McKay via curl-library <curl-library_at_cool.haxx.se>
Date: Wed, 7 Oct 2020 16:06:26 -0700

I maintain an application that uses libcurl to connect to Microsoft
Exchange servers. This is usually
outlook.office365.com but can also be private Exchange servers.

I recently updated libcurl from 7.64.1 to 7.71.1 and I'm experiencing
a problem on one particular private
server. A POST operation comes back with http error 415 (unsupported
media type) and the http feed has
the specific error text "Cannot process the message because the
content type 'application/x-www-form-urlencoded'
was not the expected type 'text/xml; charset=utf-8'.

This seems straightforward enough, except that my code *is* explicitly
setting the content-type header to be
"text/html; charset=utf-8". I do this via CURLOPT_HTTPHEADER. I have
checked and re-checked, and there is no doubt
that the curl_slist contains that header. Further proof is that when I
use this code to connect to outlook.office365.com,
it works fine and I can see the header in the returned feed, e.g.:

  Host: outlook.office365.com
  User-Agent: comaxis-agent/1.0
  Accept: */*
  X-AnchorMailbox: jjones_at_transend.onmicrosoft.com
  X-PreferServerAffinity: true
  Content-Type: text/xml; charset=utf-8
  Content-Length: 914

When I look at the log from the affected server, the headers look like this:

  Host: 10.94.194.138
  Authorization: NTLM TlRMTVNTUAAD...
  User-Agent: comaxis-agent/1.0
  Accept: */*
  X-AnchorMailbox: xxxxxxx_at_ca.ibm.com
  X-PreferServerAffinity: true
  Content-Length: 1099
  Content-Type: application/x-www-form-urlencoded

I have never set the content-type to "application/x-www-form-urlencoded".

And when I use my exact same code on this server, except switching
back to libcurl 7.64, the problem goes away, and I
see the correct content-type header in the logging.

Can anybody tell me what the issue is with 7.71? Or something in my
code? I needed to use that version to solve a separate SSL issue, so
I
don't want to go backward at this point. The affected server is
running Windows Server 2016, IIS 10.0.
-------------------------------------------------------------------
Unsubscribe: https://cool.haxx.se/list/listinfo/curl-library
Etiquette: https://curl.haxx.se/mail/etiquette.html
Received on 2020-10-08