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

Set custom request headers #47

Closed
greypants opened this issue Feb 24, 2014 · 4 comments
Closed

Set custom request headers #47

greypants opened this issue Feb 24, 2014 · 4 comments

Comments

@greypants
Copy link

It'd be great to have a headers option you can pass in, like you can with [jQuery.ajax]. I need to pass along an auth token in Authorization header.

cillosis pushed a commit to cillosis/Simple-Ajax-Uploader that referenced this issue Mar 10, 2014
cillosis pushed a commit to cillosis/Simple-Ajax-Uploader that referenced this issue Mar 10, 2014
cillosis pushed a commit to cillosis/Simple-Ajax-Uploader that referenced this issue Mar 10, 2014
LPology added a commit that referenced this issue Mar 12, 2014
Added ability to pass custom headers in request. Fixes issue #47.
@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] );
      }
    }

@cillosis
Copy link

LPology, thank you for pointing out the hasOwnProperty method, I had not used it before but it makes sense now that I read about it, it makes sense! Thank you for pulling this into the library, now I can keep up with updates!

@LPology
Copy link
Owner

LPology commented Mar 17, 2014

And thanks for your input. If you find anything else, please feel free to open an issue. I definitely appreciate it.

@LPology LPology closed this as completed Mar 17, 2014
@greypants
Copy link
Author

👍 Thanks guys!

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

No branches or pull requests

3 participants