MCPcopy
hub / github.com/ampproject/amphtml / fetchDocument

Function fetchDocument

src/document-fetcher.js:22–44  ·  view source on GitHub ↗
(win, input, opt_init)

Source from the content-addressed store, hash-verified

20 * @ignore
21 */
22export function fetchDocument(win, input, opt_init) {
23 let init = setupInit(opt_init, 'text/html');
24 init = setupAMPCors(win, input, init);
25 input = setupInput(win, input, init);
26 const ampdocService = Services.ampdocServiceFor(win);
27 const ampdocSingle = ampdocService.isSingleDoc()
28 ? ampdocService.getSingleDoc()
29 : null;
30 init.responseType = 'document';
31 return getViewerInterceptResponse(win, ampdocSingle, input, init).then(
32 (interceptorResponse) => {
33 if (interceptorResponse) {
34 return interceptorResponse
35 .text()
36 .then((body) => new DOMParser().parseFromString(body, 'text/html'));
37 }
38 return xhrRequest(input, init).then((resp) => {
39 const {xhr} = resp;
40 return xhr.responseXML;
41 });
42 }
43 );
44}
45
46/**
47 *

Callers 5

fetchDocument_Method · 0.90
authorizeOnServer_Method · 0.90
authorizeMethod · 0.90
fetchAdSensePages_Method · 0.90

Calls 9

setupInitFunction · 0.90
setupAMPCorsFunction · 0.90
setupInputFunction · 0.90
xhrRequestFunction · 0.85
getSingleDocMethod · 0.80
isSingleDocMethod · 0.45
thenMethod · 0.45
textMethod · 0.45

Tested by

no test coverage detected