Skip to content

Conversation

@Vtec234
Copy link
Contributor

@Vtec234 Vtec234 commented Jun 11, 2021

Closes #125992

To test (steps from @mjbvz):

  1. At the top of your workspace, create markdown
  2. Also create an image called img.png
  3. In markdown preview, add the content:
<script>
  fetch('img.png', {
    method: 'HEAD'
}).then(async (e) => {
    console.log(e.status);
    console.log(e.headers.get('content-type'));
    console.log(e.headers.get('content-length'));
    console.log(e.headers.get('last-modified'));
})
</script> 
  1. Open the markdown preview and make sure scripts are enabled (there should be a warning if they are not)
  2. Open the developer tools, check that the header contents have been printed and are correct
  3. Same steps for a GET request

@ghost
Copy link

ghost commented Jun 11, 2021

CLA assistant check
All CLA requirements met.

/**
* Map of requested paths to responses.
* @typedef {{ type: 'response', body: any, mime: string, etag: string | undefined, } | { type: 'not-modified', mime: string } | undefined} ResourceResponse
* @typedef {{ type: 'response', body: Uint8Array, mime: string, etag: string | undefined, mtime: number | undefined } |
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note the stronger type on body: Uint8Array. AFAICT that's the only type which is ever passed through in a response and rely on it being so to call Uint8Array.byteLength.

}

/** @type {Record<String, string>} */
/** @type {Record<string, string>} */
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo?

token: CancellationToken,
): Promise<WebviewResourceResponse.StreamResponse> {
logService.debug(`loadLocalResource - being. requestUri=${requestUri}`);
logService.debug(`loadLocalResource - begin. requestUri=${requestUri}`);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo?

@mjbvz mjbvz added this to the June 2021 milestone Jun 11, 2021
@mjbvz mjbvz merged commit 28f0fc4 into microsoft:main Jun 11, 2021
@mjbvz
Copy link
Collaborator

mjbvz commented Jun 11, 2021

Thanks! Will be in the next VS Code insiders build and is scheduled for 1.58

@Vtec234
Copy link
Contributor Author

Vtec234 commented Jun 12, 2021

Thanks! Is the macOS test failure not a concern?

@github-actions github-actions bot locked and limited conversation to collaborators Jul 27, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Provide Last-Modified and Content-Length information for webview local resources

2 participants