Skip to content

Commit 0ed7919

Browse files
SteveSandersonMSjaviercn
authored andcommitted
Fix empty response handling
1 parent 8a95a04 commit 0ed7919

File tree

4 files changed

+6
-8
lines changed

4 files changed

+6
-8
lines changed

src/Components/Web.JS/dist/Release/blazor.server.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Components/Web.JS/dist/Release/blazor.web.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Components/Web.JS/src/Services/NavigationEnhancement.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -118,11 +118,11 @@ export async function performEnhancedPageLoad(internalDestinationHref: string, f
118118
}
119119

120120
const responseContentType = response.headers.get('content-type');
121-
if (responseContentType?.startsWith('text/html')) {
121+
if (responseContentType?.startsWith('text/html') && initialContent) {
122122
// For HTML responses, regardless of the status code, display it
123123
const parsedHtml = new DOMParser().parseFromString(initialContent, 'text/html');
124124
synchronizeDomContent(document, parsedHtml);
125-
} else if (responseContentType?.startsWith('text/')) {
125+
} else if (responseContentType?.startsWith('text/') && initialContent) {
126126
// For any other text-based content, we'll just display it, because that's what
127127
// would happen if this was a non-enhanced request.
128128
replaceDocumentWithPlainText(initialContent);
@@ -248,9 +248,7 @@ function splitStream(frameBoundaryMarker: string) {
248248
}
249249
},
250250
flush(controller) {
251-
if (buffer) {
252-
controller.enqueue(buffer);
253-
}
251+
controller.enqueue(buffer);
254252
}
255253
});
256254
}

src/Components/test/E2ETest/ServerRenderingTests/FormHandlingTests/FormWithParentBindingContextTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -749,7 +749,7 @@ public async Task CanModifyTheHttpResponseDuringEventHandling()
749749

750750
[Theory]
751751
[InlineData(true)]
752-
[InlineData(false, Skip = "https://github.com/dotnet/aspnetcore/issues/49115")]
752+
[InlineData(false)]
753753
public void FormNoAntiforgeryReturnBadRequest(bool suppressEnhancedNavigation)
754754
{
755755
var dispatchToForm = new DispatchToForm(this)

0 commit comments

Comments
 (0)