Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

cfhttp + post + multipart problem

New Here ,
Apr 16, 2011 Apr 16, 2011

Hi, I’m trying to make cfhttp request with post method and multipart=”yes” attrib (trying to emulate form submiting). I use CF8 build 8.01, Wireshark, FF 3.6.16.

The problem is that I get Status code: 500 Internal Server Error in response

My cf code:

<cfscript>

request.strRAtr = {

    method="post",

      url="….",

      useragent="Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.2.15) Gecko/20110303 Firefox/3.6.15 (.NET CLR 3.5.30729)",

      redirect="no",

      multipart = "yes";

      result = "variables.strReqRes"     

};

request.arrRParam = [

      {     type = "header",

                        name="Host",

                        value="…"

                    },

     

      {     type = "header",

                        name="Accept",

                        value="text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"      

      },

     

      {     type = "header",

                        name="Accept-Language",

                        value="en-us,en;q=0.5"       

      },

     

      {     type = "header",

                        name="Accept-Encoding",

                        value="gzip,deflate"

      },

     

      {     type = "header",

                        name="Accept-Charset",

                        value="ISO-8859-1,utf-8;q=0.7,*;q=0.7"

      },

     

      {     type = "header",

                        name="Keep-Alive",

                        value="115"

      },

     

      {     type = "header",

                        name="Connection",

                        value="keep-alive"

      },

{     type = "header",

                        name="Referer",

           value="…."

            }

];

     

request.strCookieParam = {

      type="cgi",

      name="Cookie",

      value="……",

      encoded="no"           

};         

</cfscript>

<cfhttp attributecollection="#request.strRAtr#">

            <cfloop from="1" to="#arrayLen(request.arrRParam)#" index="i">

<cfhttpparam      type = "#request.arrRParam.type#"

                  name = "#request.arrRParam.name#"

                              value = "#request.arrRParam.value#">

            </cfloop>

           

<cfhttpparam      type = "formfield"

                  name = "wizardMode"

                  value = "…">

<cfhttpparam attributecollection="#request.strCookieParam#">

</cfhttp>

I’ve analysed the Wireshark – the difference between cfrequest and request from FF is in <mime_multipart chunk> (I export captured data from Wireshark into PDML – xml packet detail)

From FF I’ve get:

<proto name="mime_multipart" showname="MIME Multipart Media Encapsulation, Type: multipart/form-data, Boundary: &quot;---------------------------311112870412835&quot;" size="4585" pos="936">

    <field name="mime_multipart.type" showname="Type: multipart/form-data" size="0" pos="936" show="multipart/form-data"/>

    <field name="" show="First boundary: -----------------------------311112870412835\r\n" size="46" pos="936" value="2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d3331313131323837303431323833350d0a"/>

    <field name="mime_multipart.part" showname="Encapsulated multipart part: " size="57" pos="982" show="" value="436f6e74656e742d446973706f736974696f6e3a20666f726d2d646174613b206e616d653d2277697a6172644d6f6465220d0a0d0a74727565">

      <field name="mime_multipart.header.content-disposition" showname="Content-Disposition: form-data; name=&quot;wizardMode&quot;\r\n\r\n" size="53" pos="982" show="form-data;name=\&quot;wizardMode\&quot;" value="436f6e74656e742d446973706f736974696f6e3a20666f726d2d646174613b206e616d653d2277697a6172644d6f6465220d0a0d0a"/>

      <field name="data" value="74727565"/>

        <field name="data.data" showname="Data: 74727565" size="4" pos="1035" show="74:72:75:65" value="74727565"/>

        <field name="data.len" showname="Length: 4" size="0" pos="1035" show="4"/>

          </field>

And from CFHTTP:

<proto name="mime_multipart" showname="MIME Multipart Media Encapsulation, Type: multipart/form-data, Boundary: &quot;-----------------------------7d0d117230764&quot;" size="6297" pos="1049">

    <field name="mime_multipart.type" showname="Type: multipart/form-data" size="0" pos="1049" show="multipart/form-data"/>

    <field name="" show="First boundary: -------------------------------7d0d117230764\r\n" size="46" pos="1049" value="2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d376430643131373233303736340d0a"/>

    <field name="mime_multipart.part" showname="Encapsulated multipart part:  (text/plain)" size="98" pos="1095" show="" value="436f6e74656e742d446973706f736974696f6e3a20666f726d2d646174613b206e616d653d2277697a6172644d6f6465220d0a436f6e74656e742d547970653a20746578742f706c61696e3b20636861727365743d5554462d380d0a0d0a74727565">

      <field name="mime_multipart.header.content-disposition" showname="Content-Disposition: form-data; name=&quot;wizardMode&quot;\r\n" size="51" pos="1095" show="form-data;name=\&quot;wizardMode\&quot;" value="436f6e74656e742d446973706f736974696f6e3a20666f726d2d646174613b206e616d653d2277697a6172644d6f6465220d0a"/>

      <field name="mime_multipart.header.content-type" showname="Content-Type: text/plain; charset=UTF-8\r\n\r\n" size="43" pos="1146" show="text/plain;charset=UTF-8" value="436f6e74656e742d547970653a20746578742f706c61696e3b20636861727365743d5554462d380d0a0d0a"/>

      <proto name="data-text-lines" showname="Line-based text data: text/plain" size="4" pos="1189">

        <field name="" show="true" size="4" pos="1189" value="74727565"/>

      </proto>

    </field>

As you can see, CFHTTP creates «Encapsulated multipart part:  (text/plain)» and «data-text-lines» – why??? I suppose, that this difference is explanation of Status code: 500 Internal Server Error in response. Am I right? And what I have to do for right post in that case?

Thanks.

1.5K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 17, 2011 Apr 17, 2011
LATEST

So, my question - my answer. First of all,  my supposition about "...I suppose, that this difference is explanation of Status code: 500 Internal Server Error in response..." was WRONG!

For all people, who want to uderstand post_multipart I recomend to read RFC1341 (http://www.w3.org/Protocols/rfc1341/7_2_Multipart.html)

My problem was on another side:

I post "wrong" example in this thread -  in cfhttp I rote "...

<cfhttpparam      type = "formfield"

                  name = "wizardMode"

                  value = "…">...

"

But actualy value was "-1". In CFML Reference on p.290 I found that: "...All
form field data must be encoded in this character encoding, and ColdFusion does not
URLEncode the data..."!!!!!

That's IT !!!!!

I forgot about URLEncodedFormat function - and this was my actual problem!!!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources