21 Replies Latest reply: Mar 20, 2012 8:58 AM by Nebu23 RSS

    cfhttp and setting the content-type for a request

    Nebu23 Community Member

      Hi,

       

      I am trying to set the content-type for a cfhttp request like this (on coldfusion 9):

       

      <cfhttp redirect="no" method="get" timeout="120" url="http://10.0.0.1/test2.cfm">

          <cfhttpparam type="HEADER" name="Content-Type" value="application/json; charset=utf-8">

      </cfhttp>

       

      // coding on test2.cfm:

      <cfset x = GetHttpRequestData()>

      <cfdump var=#x#>

       

      // Output on test2.cfm

       

      content [empty string]
      headers
      struct
      Accept-Encoding deflate, gzip, x-gzip, compress, x-compress
      Connection TE
      Host 10.0.0.1:80
      Proxy-Connection close
      TE trailers, deflate, gzip, compress
      User-Agent ColdFusion
      X-REWRITE-URL http://10.0.0.1:80/test2.cfm
      method GET
      protocol HTTP/1.1

       

      As you can see no content-type is send through. I also tried the sniffer.exe:

       

      GET http://10.0.0.1:80/test2.cfm HTTP/1.1

      Host: 127.0.0.1

      Proxy-Connection: close

      Connection: TE

      TE: trailers, deflate, gzip, compress

      User-Agent: ColdFusion

      Accept-Encoding: deflate, gzip, x-gzip, compress, x-compress

       

      Here you can also see that no content-type was passed through. The sniffer should report back

       

      GET http://10.0.0.1:80/test2.cfm HTTP/1.1

      Host: 127.0.0.1

      Proxy-Connection: close

      Connection: TE

      TE: trailers, deflate, gzip, compress

      User-Agent: ColdFusion

      Accept-Encoding: deflate, gzip, x-gzip, compress, x-compress

      Content-Type: application/json; charset=utf-8

       

      But is does not, what do i need todo to set the content-type in a cfhttp request.

       

      Kind regards,

      Nebu