Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Open request in Safari with custom HTTP Headers

I have some media files on a server that are meant not to be public. They require the presence of a custom HTTP header in the request otherwise the server will just redirect to a 404 page.

I can set this custom header easily using UIWebView and NSMutableURLRequest, but I'd like to be able to open the request in Safari as well. Unfortunately it seems that the only way to open Safari is by invoking it with a simple URL with no opportunity for setting headers.

Does anyone know if there is any way to open a request in Safari with custom HTTP headers?

Thanks.

like image 216
TylerJames Avatar asked Nov 04 '22 11:11

TylerJames


1 Answers

I have not come across that feature in any browser.

You could however create an HTML page that you put on the same server, with a textfield where the user can enter a password, and then use XMLHttpRequest.setRequestHeader() to send that password to your server in an HTTP header.

It's not as straightforward as entering a URL into the address bar, so I'm not sure if that's an option for you.

like image 199
Evgeniy Berezovsky Avatar answered Nov 09 '22 14:11

Evgeniy Berezovsky