Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added ability to pass custom headers in request. Fixes issue #47. #53

Merged
merged 1 commit into from
Mar 12, 2014

Conversation

cillosis
Copy link

I love this uploader and had a real need to be able to use custom headers (specifically the Authorization header) similar to another request you had received here: #47. I went ahead and modified my copy and realized it was fairly simple to address this, so am submitting a pull request with the changes. I added documentation to the README.md file and there were a few incidental spacing changes in SimpleAjaxUploader.js. As I am not sure what you use for minification, I figured it best to let you uglify it as you see fit.

LPology added a commit that referenced this pull request Mar 12, 2014
Added ability to pass custom headers in request. Fixes issue #47.
@LPology LPology merged commit 165adfc into LPology:master Mar 12, 2014
@LPology
Copy link
Owner

LPology commented Mar 12, 2014

Thank you very much for this.

I just merged your PR, but there are a couple of changes I'm about to push. When looping through objects, it's good practice to use hasOwnProperty to distinguish between properties defined for the object and those inherited via the prototype:

    for ( var headerName in opts.customHeaders ) {
      if ( opts.customHeaders.hasOwnProperty( headerName ) ) {
        xhr.setRequestHeader( headerName, opts.customHeaders[headerName] );
      }
    }

Also, just in case you're curious, I've been using YUI compressor to minify. It seems to work well. Here's an online version:

http://yui.2clics.net/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants