Skip to content
Reimplement GNU Octave's web functions compatible to Matlab's RESTful web services.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.


Reimplement GNU Octave's web functions compatible to Matlab's RESTful web services.

Octave's state of the art.

Currently, Octave supports Matlab's deprecated web interface functions urlread and urlwrite:


both defined in libinterp/corefcn/ alongside the FTP class functions of Octave:

handle = __ftp__ (host, username, password)  % New FTP-connection.
pwd =  __ftp_pwd__  (handle)   % Print host's working directory.
list = __ftp_dir__  (handle)   % List working directory content.
mode = __ftp_mode__ (handle)   % Query transfer mode.
__ftp_ascii__  (handle)        % Set transfer mode to ASCII.
__ftp_binary__ (handle)        % Set transfer mode to binary.
__ftp_close__  (handle)        % Close FTP-connection.
__ftp_cwd__    (handle, path)  % Change host's working directory to `path`.
__ftp_delete__ (handle, path)  % Delete file `path` at host.
__ftp_rmdir__  (handle, path)  % Delete directory `path` at host.
__ftp_mkdir__  (handle, path)  % Create directory `path` at host.
__ftp_rename__ (handle, old, new)  % Rename `old` to `new` at host.
__ftp_mput__ (handle, pattern)  % Upload files matching `pattern` to host.
% Download files matching `pattern` from host to local `target` directory.
__ftp_mget__ (handle, pattern, target)

All those functions above are realized by the libcurl wrapper classes:

+----------------------+     +---------------------------+
| octave::url_transfer | --> | octave::base_url_transfer |
+----------------------+     +---------------------------+
                               | octave::curl_transfer |

Those are implemented inside liboctave/util/url-transfer.[h/cc].

The current access to web connections (for example for FTP-objects) is given by a octave::url_handle_manager implemented in libinterp/corefcn/url-handle-manager.[h/cc].

Another player in connecting to the web is the GUI. It provides a checkbox, whether Octave should be able to connect to the web for obtaining news from the community and provides settings for an HTTP-Proxy, that up to my knowledge are nowhere used. It should be stated clearly, that those options have no influence on the rest of Octave. For connecting to the web, the GUI uses octave::url_transfer directly as well.

Things to improve

  • Octave should become more Matlab compatible by implementing the RESTful web services.
    • This enables web request using cookies.
  • The security sensible web access should not spread across two libraries liboctave and libinterp.
    • Everything should go into libinterp.
    • It should be possible to opt it's functionality out, even after Octave was built, without making it useless.
  • The web access should be implemented as m-files:
    • Web access is much slower than interpreting m-files ==> no performance killer.
    • Great flexibility is gained:
      • Security evaluation by human readable actions, not compiled libraries.
      • Possibility to debug.
      • Adaption of code without waiting for the next release.

The intended design

According to the Matlab documentation, the RESTful web services consist of the following files:

  • [status, handle, url] = web (url, option1, ..., optionN) -- Open web page or file in system or builtin browser.
  • [data, cmap, alpha] = webread (url, QueryKey1, QueryVal1, ..., QueryKeyN, QueryValN, options) -- Read content from RESTful web service.
  • response = webwrite (url, PostKey1, PostVal1, ..., PostKeyN, PostValN, options) -- Write data to RESTful web service.
  • outfilename = websave (filename, url, QueryKey1, QueryVal1, ..., QueryKeyN, QueryValN, options) -- Save content from RESTful web service to file.
  • options = weboptions (Key, Value) -- Specify parameters for RESTful web service.
  • sendmail (recipients, subject, message, attachments) -- Send email message to address list.
  • ftp -- Like Octave's current FTP.

With this in mind, I would prefer an architecture like this:

|  urlread.m   |  urlwrite.m  |             |         |              |
| (deprecated) | (deprecated) |             |         |              |
+--------------+--------------+             |         |              |
|  webread.m   |  webwrite.m  |  websave.m  |  ftp.m  |  sendmail.m  |
+--------------+--------------+-------------+         |              |
|                weboptions.m               |         |              |
|  libinterp/corefun/                              |
|   |- handle = __curl_easy_init__ ()                                |
|   |- __curl_easy_cleanup__ (handle)                                |
|   |- __curl_easy_setopt__ (handle, option, param)                  |
|   |- __curl_easy_perform__ (handle)                                |
|   +- __curl_easy_getinfo__ (handle, option)                        |

Where all m-files are located in the foldes scripts\web or scripts/deprecated, respectively.

You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.