-3

Is it possible to pass dynamic data to the browser when it automatically GETs link and img and script etc tags after it has parsed the html containing them? Ultimately would want to pass an authentication token to allow the server to decide whether or not to return the resource.

Context: I am trying to help somebody with a search UI for a text file database. There is a folder on a (physical) server which the (software) server can serve static files from. There is another folder which the (software) server is configured not to serve static files from. So if somebody puts in the URL for an image (for example) in the private folder, nothing is returned. I want to be able to send a token (stored in session if the user has logged in) along with all initial GET requests as the browser loads the page. So if you are logged in, the server will see the token and return files from the private folder. I have a Python/WSGI setup at the server so can check for the token to determine whether or not to return data from the private folder. Since the browser GETs the initial resources automatically I don't see how I can add my token.

  • Judging by the down-votes this is a stupid question? Could somebody please explain why? – James Izzard Aug 11 '16 at 14:18
  • 1
    Anything is possible given enough time, money and programmer effort. I'm not even quite sure what you're asking here. – Robert Harvey Aug 11 '16 at 14:31
  • Is there a method of asking the browser to pass a string to the server when auto-loading resources? I guess probably with JavaScript. So when it gets image.svg it adds a string to the header? This is obviously possible with an ajax request or whatever, but is it possible as the browser collects its immediate resources referenced on the page? – James Izzard Aug 11 '16 at 14:51
  • 1
    Your question suffers quite a bit from the X Y problem: rather than asking about the problem you're trying to solve, you're asking about your attempted solution to the unstated problem. What is the actual problem you're trying to solve? – Robert Harvey Aug 11 '16 at 14:52
  • @RobertHarvey I have added context to the original question in response to your comments. – James Izzard Aug 11 '16 at 15:26
0

This is what I was looking for: https://developer.mozilla.org/en/docs/Setting_HTTP_request_headers In particular the section on creating an observer to listen for the notification "http-on-modify-request". Appreciate the advice regardless.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.