Skip to content

Commit

Permalink
Handle 304s for remote resources
Browse files Browse the repository at this point in the history
Now that we send along etag caching headers, the remote can return 304s. Make sure we forward these
  • Loading branch information
mjbvz committed Feb 9, 2021
1 parent 29844a0 commit 5180973
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
12 changes: 9 additions & 3 deletions src/vs/platform/webview/common/resourceLoader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,16 @@ export async function loadLocalResource(

logService.debug(`loadLocalResource - Loaded over http(s). requestUri=${requestUri}, response=${response.res.statusCode}`);

if (response.res.statusCode === 200) {
return new WebviewResourceResponse.StreamSuccess(response.stream, response.res.headers['etag'], mime);
switch (response.res.statusCode) {
case 200:
return new WebviewResourceResponse.StreamSuccess(response.stream, response.res.headers['etag'], mime);

case 304: // Not modified
return new WebviewResourceResponse.NotModified(mime);

default:
return WebviewResourceResponse.Failed;
}
return WebviewResourceResponse.Failed;
}

try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ export class WebviewProtocolProvider extends Disposable {
}, fileReader, this.requestService, this.logService, CancellationToken.None);

switch (result.type) {
case WebviewFileReadResponse.Type.Success:
case WebviewResourceResponse.Type.Success:
{
const cacheHeaders: Record<string, string> = result.etag ? {
'ETag': result.etag,
Expand Down

0 comments on commit 5180973

Please sign in to comment.