NASAWorldWind / WebWorldWind

The NASA WorldWind Javascript SDK (WebWW) includes the library and examples for creating geo-browser web applications and for embedding a 3D globe in HTML5 web pages.
898 stars 384 forks source link

Network service #154

Open AkeluX opened 7 years ago

AkeluX commented 7 years ago

Many components (layers, format parsers...) obtain external data via XMLHttpRequests. It is currently the responsibility of each component to build and handle its requests. This introduced some variations in the options that can be provided for the requests, in the handling of errors and timeouts, etc.

A unified approach using a library or a dedicate utility class would harmonise the way external requests are made and can be configured by the application.

We are currently looking into all the cases in the SDK in order to formulate a proposition on how to move forward on this topic.

pdavidc commented 6 years ago

@AkeluX I'd like to expand the scope of this to include an overall unified network retrieval architecture. There's fragmentation beyond WorldWind's use of XMLHttpRequest. Components such as TiledImageLayer retrieve images via the browser's HTMLImageElement. While the image object offers several benefits (browser image caching, built-in thread pooling, better HTTP redirection support), its use also complicates and fragments WorldWind's internal network retrieval logic.

Additionally, the capability of connecting to OGC web services via HTTP POST may be complicated by HTMLImageElement, which seems to support only HTTP GET resources.

balhar-jakub commented 6 years ago

I really like the idea to expand this to include overall network retrieval architecture. I believe that it is one of the thing that makes implementation of new features more complicated.

As you say the HTMLImageElement really does support only the GET HTTP request.

There is a new Fetch API that should replace in the future the XMLHttpRequest. https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API There are polyfills for older browsers as well as there is an implementation for node.js which seems to becoming the standard for retrieval of remote resources. (https://github.com/github/fetch)

I believe that if we provide the standardized way to work with network resources throughout the framework, it should be built around the similar concepts such as the fetch api was built around.

AkeluX commented 6 years ago

Note: for us, it would be useful to allow requests to be "proxied" by prefixing them with another server address.