diff --git a/core/lib/Drupal/Core/StreamWrapper/LocalReadOnlyStream.php b/core/lib/Drupal/Core/StreamWrapper/LocalReadOnlyStream.php
index 1b14280..2a549ea 100644
--- a/core/lib/Drupal/Core/StreamWrapper/LocalReadOnlyStream.php
+++ b/core/lib/Drupal/Core/StreamWrapper/LocalReadOnlyStream.php
@@ -28,19 +28,20 @@
    * @param string $uri
    *   A string containing the URI to the file to open.
    * @param int $mode
-   *   The file mode (only "r" is supported for the read-only stream wrapper.)
+   *   The file mode, only strict readonly modes are supported.
    * @param int $options
    *   A bit mask of STREAM_USE_PATH and STREAM_REPORT_ERRORS.
    * @param string $opened_path
    *   A string containing the path actually opened.
    *
    * @return bool
-   *   Returns TRUE if $mode == "r" and the file was opened successfully.
+   *   TRUE if $mode denotes a readonly mode and the file was opened
+   *   successfully, FALSE otherwise.
    *
    * @see http://php.net/manual/streamwrapper.stream-open.php
    */
   public function stream_open($uri, $mode, $options, &$opened_path) {
-    if ($mode != "r") {
+    if (!in_array($mode, array('r', 'rb', 'rt'))) {
       if ($options & STREAM_REPORT_ERRORS) {
         trigger_error('stream_open() write modes not supported for read-only stream wrappers', E_USER_WARNING);
       }
@@ -114,6 +115,8 @@ public function stream_write($data) {
    * Support for fflush().
    *
    * Nothing will be output to the file, as this is a read-only stream wrapper.
+   * However as stream_flush is called during stream_close we should not trigger
+   * an error.
    *
    * @return bool
    *   FALSE, as no data will be stored.
@@ -121,7 +124,6 @@ public function stream_write($data) {
    * @see http://php.net/manual/streamwrapper.stream-flush.php
    */
   public function stream_flush() {
-    trigger_error('stream_flush() not supported for read-only stream wrappers', E_USER_WARNING);
     return FALSE;
   }
 
diff --git a/core/lib/Drupal/Core/StreamWrapper/ReadOnlyStream.php b/core/lib/Drupal/Core/StreamWrapper/ReadOnlyStream.php
index 2ebcc06..6125455 100644
--- a/core/lib/Drupal/Core/StreamWrapper/ReadOnlyStream.php
+++ b/core/lib/Drupal/Core/StreamWrapper/ReadOnlyStream.php
@@ -63,19 +63,20 @@ function getUri() {
    * @param string $uri
    *   A string containing the URI to the file to open.
    * @param int $mode
-   *   The file mode (only "r" is supported for the read-only stream wrapper.)
+   *   The file mode, only strict readonly modes are supported.
    * @param int $options
    *   A bit mask of STREAM_USE_PATH and STREAM_REPORT_ERRORS.
    * @param string $opened_path
    *   A string containing the path actually opened.
    *
    * @return bool
-   *   Returns TRUE if $mode == "r" and the file was opened successfully.
+   *   TRUE if $mode denotes a readonly mode and the file was opened
+   *   successfully, FALSE otherwise.
    *
    * @see http://php.net/manual/streamwrapper.stream-open.php
    */
   public function stream_open($uri, $mode, $options, &$opened_path) {
-    if ($mode != "r") {
+    if (!in_array($mode, array('r', 'rb', 'rt'))) {
       if ($options & STREAM_REPORT_ERRORS) {
         trigger_error('stream_open() write modes not supported for read-only stream wrappers', E_USER_WARNING);
       }
@@ -148,6 +149,8 @@ public function stream_write($data) {
    * Support for fflush().
    *
    * Nothing will be output to the file, as this is a read-only stream wrapper.
+   * However as stream_flush is called during stream_close we should not trigger
+   * an error.
    *
    * @return bool
    *   FALSE, as no data will be stored.
@@ -155,7 +158,6 @@ public function stream_write($data) {
    * @see http://php.net/manual/streamwrapper.stream-flush.php
    */
   public function stream_flush() {
-    trigger_error('stream_flush() not supported for read-only stream wrappers', E_USER_WARNING);
     return FALSE;
   }
 
diff --git a/core/modules/system/lib/Drupal/system/Tests/File/ReadOnlyStreamWrapperTest.php b/core/modules/system/lib/Drupal/system/Tests/File/ReadOnlyStreamWrapperTest.php
index 909fe1c..d043de5 100644
--- a/core/modules/system/lib/Drupal/system/Tests/File/ReadOnlyStreamWrapperTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/File/ReadOnlyStreamWrapperTest.php
@@ -53,9 +53,17 @@ function testWriteFunctions() {
     $uri = $this->scheme . '://' . $filename;
     $instance = file_stream_wrapper_get_instance_by_scheme($this->scheme);
 
-    // Attempt to open a file in write mode
-    $handle = @fopen($uri, 'w+');
-    $this->assertFalse($handle, 'Unable to open a file for writing with the read-only stream wrapper.');
+    // Attempt to open a file in read/write mode
+    $handle = @fopen($uri, 'r+');
+    $this->assertFalse($handle, 'Unable to open a file for reading and writing with the read-only stream wrapper.');
+    // Attempt to open a file in binary read mode
+    $handle = fopen($uri, 'rb');
+    $this->assertTrue($handle, 'Able to open a file for reading in binary mode with the read-only stream wrapper.');
+    $this->assertTrue(fclose($handle), 'Able to close file opened in binary mode using the read_only stream wrapper.');
+    // Attempt to open a file in text read mode
+    $handle = fopen($uri, 'rt');
+    $this->assertTrue($handle, 'Able to open a file for reading in text mode with the read-only stream wrapper.');
+    $this->assertTrue(fclose($handle), 'Able to close file opened in text mode using the read_only stream wrapper.');
     // Attempt to open a file in read mode
     $handle = fopen($uri, 'r');
     $this->assertTrue($handle, 'Able to open a file for reading with the read-only stream wrapper.');
@@ -72,7 +80,7 @@ function testWriteFunctions() {
     // Attempt to flush output to the file
     $this->assertFalse(@fflush($handle), 'Unable to flush output to file using the read-only stream wrapper.');
     // Attempt to close the stream.  (Suppress errors, as fclose triggers fflush.)
-    $this->assertTrue(@fclose($handle), 'Able to close file using the read_only stream wrapper.');
+    $this->assertTrue(fclose($handle), 'Able to close file using the read_only stream wrapper.');
     // Test the rename() function
     $this->assertFalse(@rename($uri, $this->scheme . '://newname.txt'), 'Unable to rename files using the read-only stream wrapper.');
     // Test the unlink() function
