1

Environment:

Windows Server 2012 Standard
rhodes-3.5.1.13 - MotorolaRhoMobileSuite2.2.1.13
jQuery Mobile 1.6.4
Java jdk1.6.0_24

Description: After making this call..


    Rho::AsyncHttp.get( 
    :url => url, 
    :headers => { 
    'Accept'=>'application/json', 
    'Accept-Encoding'=>'gzip,deflate,sdch', 
    'Accept-Language'=>'en-US,en;q=0.8' 
    }, 
    :callback => callback, 
    :callback_param => callback_param 
    ) 

...the result of this request returns the following:


    "Rho::AsyncHttp....callback_param)" {"rho_callback"=>"1", "status"=>"error", "error_code"=>"1", "headers"=>{"Accept"=>"application/json", "Accept-Encoding"=>"gzip,deflate,sdch", "Accept-Language"=>"en-US,en;q=0.8", "User-Agent"=>"Mozilla-5.0 (ANDROID; Win32; 4.0.3)"}, "body"=>""}

Question: Is there a Rhomobile limitation on the headers that I am allowed to pass to this call? It seems to work if I paste the url, with the headers, into Fiddler. When I remove 'Accept-Encoding'=>'gzip,deflate,sdch', the response is the same.

Thanks in advance.

Max Revine
  • 78
  • 6

1 Answers1

0

Rhodes uses libcURL for implementing the AsyncHTTP API in v3.5 of the framework as is possible to see in the sourcecode.

So whatever is possible to do in libcURL, the same is possible to do in ASyncHTTP.

In your particular case I'll probably use the "Content-Type" instead of the "Accept" header:

 Rho::AsyncHttp.get( 
    :url => url, 
    :headers => { 
    'Content-Type'=>'application/json', 
    'Accept-Encoding'=>'gzip,deflate,sdch', 
    'Accept-Language'=>'en-US,en;q=0.8' 
    }, 
    :callback => callback, 
    :callback_param => callback_param 
    ) 

If you want to test this in Rhodes v4.0, there now the Network API that you can use in the same way:

getProps = Hash.new
getProps['url'] = url
getProps['headers'] = {"Content-Type" => "application/json",
                       "Accept-Encoding"=>"gzip,deflate,sdch", 
                       "Accept-Language"=>"en-US,en;q=0.8"}
Rho::Network.get(getProps, url_for(:action => :callback))
pfmaggi
  • 6,116
  • 22
  • 43