9 Replies Latest reply on Apr 23, 2009 9:36 AM by ATIF FAROOQ

    HttpService

    ATIF FAROOQ Level 3

      hi,

         Is there any way to get httpHeaders sent by the server in response to http Reqeuest ?

        • 1. Re: HttpService
          thedex1 Level 1

          Create php cURL code to get headers and use that php file as URL property of HttpService..

          Hope this help. ..

          • 2. Re: HttpService
            ATIF FAROOQ Level 3

            cant i get headers if i utilize Flex Socket and make tcp Http Request to read all UTfBytes Available including headers?

            • 3. Re: HttpService
              wvxvw Level 1

              Sure you can.

              • 4. Re: HttpService
                ATIF FAROOQ Level 3

                yes i tried that but i get this sand box violation errror when i accesss it

                 

                Error #2044: Unhandled securityError:. text=Error #2048: Security sandbox violation: app:/ cannot load data from 10.16.6.16:80

                 

                and my constructed request is this

                 

                 

                var httprequest:String=new String()
                httprequest="GET "+statusurl+" HTTP/1.1\r\n"
                sock.writeUTFBytes(httprequest)
                //cookieHandler.writeUTFBytes(httprequest)
                httprequest="Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5\r\n"
                sock.writeUTFBytes(httprequest)
                //httprequest="x-flash-version: 10,0,12,36\r\n"
                //cookieHandler.writeUTFBytes(httprequest)
                httprequest="User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US) AppleWebKit/525.19 (KHTML, like Gecko) Chrome/1.0.154.53 Safari/525.19\r\n"
                sock.writeUTFBytes(httprequest)
                httprequest="Host: internet.wateen.net\r\n"
                sock.writeUTFBytes(httprequest)
                httprequest="Connection: Keep-Alive\r\n\r\n"
                sock.writeUTFBytes(httprequest)
                httprequest="Accept-Charset: ISO-8859-1,*,utf-8\r\n"
                sock.writeUTFBytes(httprequest)
                sock.flush()
                
                

                 

                 

                   and this is response from server

                 

                Untitled-1.jpg

                   why flex considering it as sand box violation ?

                • 5. Re: HttpService
                  wvxvw Level 1

                  1. Probably your app is not loaded from 10.16.6.16:80 (and if URLs are not identical it will give you the security error). Mind that identical !== same physical address. i.e. 10.16.6.16:80 !== http://10.16.6.16 (even though most probably that will be the same script responding on the other side).

                  Another thing is that when connecting through the socket the connection is restricted by default, it is permitted only if the port you're trying to connect replies to the policy file request with the valid policy data. This meant that when your socket on 10.16.6.16:80 is asked for

                  <policy-file-request/>

                  it should print out the policy file followed by the null byte (\x00) to grant the client permision to connect to it.

                  Please read this article for more info:

                  http://www.adobe.com/devnet/flashplayer/articles/socket_policy_files.html

                  • 6. Re: HttpService
                    ATIF FAROOQ Level 3

                    Yes server is doing redirection in the middle that is causing violation problem i think.But i am building this Application in Air .and i dont  have idea if server enviornment implements socket policy file permissions because its a third party server.Most probbably they will not because that server is not intended to use in a such manner from flash .I think in Air there should be no sandbox violation problem of this kind no ? Altough thanks for helpful answer.

                    • 7. Re: HttpService
                      wvxvw Level 1

                      This is something I'm not sure about... but I'd guess that it may depend on AIR runtime version (maybe in 1.1 the security restrictions where less restrictive). But as far as I'm concerned, the socket must implement this security feature...

                      • 8. Re: HttpService
                        Peter Farland Level 3

                        Hi,

                         

                        HTTPService was designed before AIR, and given the Flash Player does not provide access to HTTP response headers the HTTPService API does not expose a way to get them.

                         

                        If you can get by with manually formatting the request and response data then I suggest using the flash.net.URLLoader class directly (as this is what HTTPService ultimately uses to make the request). For AIR applications you can add an event listener for the "httpResponseStatus" event to get the information you're looking for... see:

                         

                        http://livedocs.adobe.com/flex/3/langref/flash/net/URLLoader.html#event:httpResponseStatus

                         

                        Note that in AIR the associated HTTPStatusEvent instance has three useful properties:

                         

                        responseURL - The URL from which the response was returned.

                        responseHeaders - The response headers that the response returned, as an array of URLRequestHeader objects.

                        status - The HTTP status code returned by the server.

                         

                        Pete

                        1 person found this helpful
                        • 9. Re: HttpService
                          ATIF FAROOQ Level 3

                          Thanks alot Thats what i was looking for . live long life