Переглянути джерело

LibWeb: Set document content type in load_document()

Fixes regression in `load_document()` compared to FrameLoader.
Aliaksandr Kalenik 1 рік тому
батько
коміт
b7c93cae7f
1 змінених файлів з 4 додано та 0 видалено
  1. 4 0
      Userland/Libraries/LibWeb/DOM/DocumentLoading.cpp

+ 4 - 0
Userland/Libraries/LibWeb/DOM/DocumentLoading.cpp

@@ -235,6 +235,10 @@ JS::GCPtr<DOM::Document> load_document(Optional<HTML::NavigationParams> navigati
 
 
     if (navigation_params->response->body()) {
     if (navigation_params->response->body()) {
         auto process_body = [navigation_params, document](ByteBuffer bytes) {
         auto process_body = [navigation_params, document](ByteBuffer bytes) {
+            auto extracted_mime_type = navigation_params->response->header_list()->extract_mime_type().release_value_but_fixme_should_propagate_errors();
+            auto mime_type = extracted_mime_type.has_value() ? extracted_mime_type.value().essence().bytes_as_string_view() : StringView {};
+            document->set_content_type(mime_type);
+
             if (!parse_document(*document, bytes)) {
             if (!parse_document(*document, bytes)) {
                 // FIXME: Load html page with an error if parsing failed.
                 // FIXME: Load html page with an error if parsing failed.
                 TODO();
                 TODO();