0 Replies Latest reply on Aug 30, 2012 8:27 PM by Steve Pallen

    Rho::AsyncHttp.upload_file on blackberry does not send content-length

      The following code works for iPhone, rhosimulator, but fails on bb simulators. I'm using SDK 6.0. The server is returning a 411 error indicating missing content length.

      def post_to_server(value, params)

          app_info("--> value_controller post_to_server params: #{params}")

          settings = Settings.get

          url = "#{Settings.server}/map/value/0/edit?mobileapp=1"

       

       

          Rho::AsyncHttp.upload_file(

            :url => url,

            :headers => {"Cookie" => "#{settings.cookies}"},

            :callback => url_for( :action => :post_value_callback),

            :callback_param => '',

            :multipart => [

              {

                :name => 'picture',

                :filename => value.image.url,

                :content_type => 'image/jpeg'

       

       

              },

              {

                :body => value.value,

                :name => 'value',

                :content_type => "plain/text"

              },

              {

                :name => 'text',

                :body => value.text,

                :content_type => "plain/text"

              }

            ]

          )

        end

       

       

      Here is a wireshark trace of the failure case:

       

       

      POST /map/value/0/edit?mobileapp=1 HTTP/1.1

      Host: <snip>

      Connection: keep-alive

      content-type: multipart/form-data; boundary=----------A6174410D6AD474183FDE48F5662FCC5

      Cookie: django_language=en;Path=/;sessionid=c5ae9ec90882b8591700708d680b4d71;Max-Age=1209600;Path=/;

      User-Agent: Mozilla-5.0 (Blackberry; 9800; 6.0.0.396)

      Transfer-Encoding: chunked

       

       

      100000

      ------------A6174410D6AD474183FDE48F5662FCC5

      Content-Disposition: form-data; name="picture"; filename="image_Aug_29_2012_15_41_07_America_New_York.jpg"

      Content-Type: image/jpeg

      Content-Length: 1505028

       

       

      ......Exif..II*.....

      <snip>

       

       

      HTTP/1.1 411 Length Required

      Date: Wed, 29 Aug 2012 19:56:25 GMT

      Server: Apache/2.2.20 (Ubuntu)

      Vary: Accept-Encoding

      Content-Length: 324

      Connection: close

      Content-Type: text/html; charset=iso-8859-1

       

       

      <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">

      <html><head>

      <title>411 Length Required</title>

      </head><body>

      <h1>Length Required</h1>

      <p>A request of the requested method POST requires a valid Content-length.<br />

      </p>

      <hr>

      <snip>

      </body></html>

      ..U:F......MJ..%.8...n..]R.n."#.?........W............w..m..6...m.

       

       

      Here is a wireshark trace of a successful rhosimulator case:

       

       

      POST /map/value/0/edit?mobileapp=1 HTTP/1.1

      Cookie: sessionid=9c8f5b047391ae06b5f1135ede85a159;Max-Age=1209600;Path=/;django_language=en;Path=/;

      User-Agent: Mozilla-5.0 (Blackberry; Win32; 6.0)

      Content-Type: multipart/form-data; boundary=----------A6174410D6AD474183FDE48F5662FCC5

      Host: <snip>

      Content-Length: 846470

      Connection: Keep-Alive

      Cache-Control: no-cache

       

       

      ------------A6174410D6AD474183FDE48F5662FCC5

      Content-Disposition: form-data; name="picture"; filename="Image_07-29-2012_20.06.59_-004.jpg"

      Content-Type: image/jpeg

      Content-Length: 845941

       

       

      ......JFIF.....`.`....

      <snip>

      ------------A6174410D6AD474183FDE48F5662FCC5

      Content-Disposition: form-data; name="value"

      Content-Type: plain/text

      Content-Length: 1

      4

      -----------A6174410D6AD474183FDE48F5662FCC5

      Content-Disposition: form-data; name="text"

      Content-Type: plain/text

      Content-Length: 6

      dfgdfg

      -----------A6174410D6AD474183FDE48F5662FCC5--HTTP/1.1 200 OK

      Date: Wed, 29 Aug 2012 20:07:39 GMT

      Server: Apache/2.2.20 (Ubuntu)

      Vary: Accept-Language,Cookie,Accept-Encoding

      Access-Control-Allow-Origin: *

      Access-Control-Allow-Methods: POST,GET,OPTIONS,PUT,DELETE

      Content-Language: en

      Set-Cookie:  sessionid=9c8f5b047391ae06b5f1135ede85a159; expires=Wed, 12-Sep-2012 20:07:49 GMT; Max-Age=1209600; Path=/

      Keep-Alive: timeout=15, max=100

      Connection: Keep-Alive

      Transfer-Encoding: chunked

      Content-Type: application/javascript

      d

      {"status": 1}

      0