Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

X-Requested-With header
  • JQuery and other libraries set the X-Requested-With header in the request to XMLHttpRequest

    Some frameworks and coding will therefore rely on this header to detect whether a particular request is ajax-related (Zend Framework among them) and respond accordingly. Therefore an option to be able to specify this header be set in the flash request would be very helpful:
    X-Requested-With: XMLHttpRequest


    Setting such a header would also mimic the behavior of jQuery ajax calls (which automatically set this header).

    EDIT: Even better would be to allow the user to set _any_ header. But at the very least, the above header would be most helpful and make this more jQuery friendly.
  • I agree, and being able to set headers will also allow basic authentication to be used. Unfortunately the smart people at Adobe have disabled the ability to send additional headers through flash for file uploads.

    Until Adobe change their minds on this there's nothing we can do.
  • Wow, I am surprised to hear that (although I see it everywhere now that I look into the issue).

    Here is my work-around for this issue which uses PHP. This is specific to Zend Framework, but the general idea can be applied to any script.

    In my script, I look for PHPSESSID param (which is sent by me using scriptData config of uploadify) and if found I inject my desired header into $_SERVER array (where Zend Framework looks for request headers).

    Bootloader.php class:

    protected function _initSession()
    {
    // Flash uploads require being able to specify session id
    if ($_POST['PHPSESSID'])
    {
    // TODO: Fix uploadify/flash to work without this hack
    // until Requested with header set to XMLHttpRequest for uploadify
    // (and headers supported for file uploads in flash)
    $_SERVER['HTTP_X_REQUESTED_WITH'] = \"XMLHttpRequest\";

    Zend_Session::setId($_POST['PHPSESSID']);
    }
    }


    Note: You should check POST or GET params, but not REQUEST since REQUEST contains cookies (which may contain PHPSESSID and therefore incorrectly label this an XMLHttpRequest). This also assumes PHPSESSID is not being sent along with your standard links on your page (only with flash/uploadify requests).