javascript - Node.js: How to detect html embedded request vs XMLHttpRequest? -



javascript - Node.js: How to detect html embedded request vs XMLHttpRequest? -

in node.js (or in web server matter), somehow possible able determine whether resource request came embedded element in html document, opposed scripted request?

for instance, if have in .html file:

<script src="/testroute.js"></script>

and in javascript:

var xhr = new xmlhttprequest(); xhr.open("get", '/testroute.js', true); xhr.send();

is there way server can distinguish between these 2 requests?

the same origin policy applies differently in each case, there apparently differentiation going on (at to the lowest degree under surface). there way server developer can see difference?

just personal experiment, using diff tool, compared express req object received each , saw 2 slight differences:

the socket, connection, , client properties in <script> originating req object had [function]s error property, whereas these [object] request originated xmlhttprequest.

the headers property contained cache-control: 'max-age=0' in request originated xmlhttprequest not <script> request.

i don't know means, , don't know if these results consistent across browsers, consistent @ to the lowest degree between chrome , firefox.

javascript html node.js

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -