oooyaya
oooyaya

Reputation: 1783

Add header to <img> GET

Is there any way to add a header to a standard HTML tag?

What we have is: /path/to/image.png

Except this is actually a RESTful endpoint, and it requires a userID header.

GET /path/to/image.png
Header
userId: BobLoblaw

This returns a bytestream and poof, image.

However, we hope to use this right in an image tag. Is that possible without Apache forcing an outgoing userId?

I'm hoping for something like

imageProvider.get().then(function(response) {
   // do something with the resultant bytestream
})

Note - this is NOT base64 transcoding. It's an actual image stream.

Upvotes: 1

Views: 98

Answers (1)

Matt Ball
Matt Ball

Reputation: 359816

No, that's not possible. You don't get to control the request headers that the browser sends along with a GET request for an <img> tag.

Use a query parameter in the URL.

Upvotes: 2

Related Questions