15

I would like to understand the low level details of how XMLHttpRequest works in Javascript, however I have not had any luck finding the implementation code within either the Rhino or V8 code. I'm not familiar with the code in either projects, so I may not be looking in the right spots.

Is there an available open-source implementation anywhere?

durron597
  • 31,968
  • 17
  • 99
  • 158
Steve
  • 53,375
  • 33
  • 96
  • 141
  • 6
    I suspect that it's a facility provided by the *browser*, not the Javascript engine. Recall that in IE it was originally an ActiveX component. – Pointy Jul 01 '10 at 12:08
  • 3
    Pointy is right. XMLHttpPrequest is a DOM api, so in Chrome's case it would be provided by webkit, not v8: http://trac.webkit.org/browser/trunk/WebCore/xml/XMLHttpRequest.cpp – Crescent Fresh Jul 01 '10 at 12:30
  • Crescent, your link no longer works. – Billbad Mar 03 '12 at 00:32
  • Also regarding the IE implementation, it extends farther out to the Windows Scripting Host (WSH) such that you can use XmlHttpRequest functionality by using the applicable ActiveX component that's typically standard on Windows. So you can then use it in command line javascript on Windows (via WSH). Not sure if you get similar wiht Rhino, but you do with node.js executing XmlHttpRequest. – David Jul 20 '12 at 00:31
  • For newer versions of IE (IE 7+), they support the XmlHttpRequest() method natively (though don't know if internally it uses ActiveX component or not. But on IE 6 and earlier you specifically had to invoke the Active X component (or wrap XmlHttpRequest call to call that) in order to use it. There was no XmlHttpRequest object in older versions of IE. – David Jul 20 '12 at 00:33
  • 1
    This is the new link for webkit: http://trac.webkit.org/browser/trunk/Source/WebCore/xml/XMLHttpRequest.cpp – trappedIntoCode May 14 '13 at 12:10
  • Another link: https://chromium.googlesource.com/chromium/blink/+/refs/heads/master/Source/core/xmlhttprequest/XMLHttpRequest.cpp – yaobin May 02 '19 at 15:39

1 Answers1

7

If I'm not mistaken, in the Mozilla source code this is handled by nsXMLHttpRequest.cpp.

Marcel Korpel
  • 21,536
  • 6
  • 60
  • 80