Repository: NCAS-CMS/cfdm

Issue:
Reading `https://` netCDF files does not work
At version 1.10.1.1, reading a `https://` files does not work, but reading an `http://` file does work:

```python
>>> import cfdm
>>> remote = "http://psl.noaa.gov/thredds/dodsC/Datasets/cru/crutem5/Monthlies/air.mon.anom.nobs.nc"
>>> cfdm.read(remote)
[<Field: air_temperature_anomaly(time(2082), latitude(36), longitude(72)) observations>]
>>> remote = "https://psl.noaa.gov/thredds/dodsC/Datasets/cru/crutem5/Monthlies/air.mon.anom.nobs.nc"
>>> cfdm.read(remote)
--------------------------------------------------------------------------
OSError                                   Traceback (most recent call last)
Cell In[3], line 1
----> 1 f = cfdm.read(remote)

File ~/cfdm/cfdm/read_write/read.py:360, in read(filename, external, extra, verbose, warnings, warn_valid, mask, domain, _implementation)
    355     raise IOError(
    356         f"Can't determine format of file {filename} "
    357         f"generated from CDL file {cdl_filename}"
    358     )
    359 else:
--> 360     raise IOError(f"Can't determine format of file {filename}")
    362 # ----------------------------------------------------------------
    363 # Return the field or domain constructs
    364 # ----------------------------------------------------------------
    365 return fields

OSError: Can't determine format of file https://psl.noaa.gov/thredds/dodsC/Datasets/cru/crutem5/Monthlies/air.mon.anom.nobs.nc
```
This is due to a simple bug in `cfdm.read_write.netcdf.netcdfread.is_netcdf_file`. PR to follow.

Comments:

Patch:
diff --git a/Changelog.rst b/Changelog.rst
index e4e178769..5cf7d255c 100644
--- a/Changelog.rst
+++ b/Changelog.rst
@@ -1,3 +1,13 @@
+Version 1.10.1.2
+----------------
+
+**2023-08-31**
+
+* Fix bug that prevented "https://" netCDF files from being read
+  (https://github.com/NCAS-CMS/cfdm/issues/268)
+
+----
+
 Version 1.10.1.1
 ----------------
 
diff --git a/cfdm/read_write/netcdf/netcdfread.py b/cfdm/read_write/netcdf/netcdfread.py
index c3c3c8c75..e6a6295cd 100644
--- a/cfdm/read_write/netcdf/netcdfread.py
+++ b/cfdm/read_write/netcdf/netcdfread.py
@@ -481,8 +481,10 @@ class NetCDFRead(IORead):
     def is_netcdf_file(cls, filename):
         """Return `True` if the file is a netCDF file.
 
-        Note that the file type is determined by inspecting the file's
-        contents and any file suffix is not not considered.
+        The file type is determined by inspecting the file's contents
+        and any file suffix is not not considered. However, file names
+        starting ``https://`` or ``http://`` are assumed, without
+        checking, to be netCDF files.
 
         :Parameters:
 
@@ -501,7 +503,7 @@ class NetCDFRead(IORead):
 
         """
         # Assume that URLs are in netCDF format
-        if filename.startswith("http://"):
+        if filename.startswith("https://") or filename.startswith("http://"):
             return True
 
         # Read the magic number


Test patch:
diff --git a/cfdm/test/test_read_write.py b/cfdm/test/test_read_write.py
index ec27b0207..e60779cb7 100644
--- a/cfdm/test/test_read_write.py
+++ b/cfdm/test/test_read_write.py
@@ -985,12 +985,11 @@ class read_writeTest(unittest.TestCase):
 
     def test_read_url(self):
         """Test reading urls."""
-        remote = "http://psl.noaa.gov/thredds/dodsC/Datasets/cru/crutem5/Monthlies/air.mon.anom.nobs.nc"
-        # Check that the file remote is indeed accesible
-        _ = netCDF4.Dataset(remote, "r")
-        # Check that cfdm can access it
-        f = cfdm.read(remote)
-        self.assertEqual(len(f), 1)
+        for scheme in ("http", "https"):
+            remote = f"{scheme}://psl.noaa.gov/thredds/dodsC/Datasets/cru/crutem5/Monthlies/air.mon.anom.nobs.nc"
+            # Check that cfdm can access it
+            f = cfdm.read(remote)
+            self.assertEqual(len(f), 1)
 
 
 if __name__ == "__main__":