Let's say I have a code like this:
<img src='images/whatever.jpj' width='' height=''/>
How to configure custom headers for this request?
Will appreciate any help.
In the Home pane, double-click HTTP Response Headers. In the HTTP Response Headers pane, click Add... in the Actions pane. In the Add Custom HTTP Response Header dialog box, set the name and value for your custom header, and then click OK.
Custom HTTP headers are commonly meant to provide additional information that may be pertinent to a web developer, or for troubleshooting purposes. These headers often times begin with X- , however, we'll discuss naming convention further on.
I'm late here, but you can do this with XMLHttpRequest
and a blob.
var xhr = new XMLHttpRequest(); xhr.responseType = 'blob'; //so you can access the response like a normal URL xhr.onreadystatechange = function () { if (xhr.readyState == XMLHttpRequest.DONE && xhr.status == 200) { var img = document.createElement('img'); img.src = URL.createObjectURL(xhr.response); //create <img> with src set to the blob document.body.appendChild(img); } }; xhr.open('GET', 'http://images.example.com/my_secure_image.png', true); xhr.setRequestHeader('SecretPassword', 'password123'); xhr.send();
If you want, you could check to make sure the blob's MIME type is an image.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With