mGet method Null safety

  1. @JS('get')
String? mGet(
  1. String name
)
@JS('get')

Returns a ByteString sequence of all the values of a header within a Headers object with a given name. myHeaders.get(name); Creating an empty Headers object is simple:

var myHeaders = new Headers(); // Currently empty myHeaders.get('Not-Set'); // Returns null You could add a header to this using Headers.append, then retrieve it using get():

myHeaders.append('Content-Type', 'image/jpeg'); myHeaders.get('Content-Type'); // Returns "image/jpeg" If the header has multiple values associated with it, the byte string will contain all the values, in the order they were added to the Headers object:

myHeaders.append('Accept-Encoding', 'deflate'); myHeaders.append('Accept-Encoding', 'gzip'); myHeaders.get('Accept-Encoding'); // Returns "deflate,gzip" myHeaders.get('Accept-Encoding').split(',').map(v => v.trimStart()); // Returns "deflate", "gzip"

Note: Headers.getAll used to have this functionality, with Headers.get returning only the first value added to the Headers object. The latest spec has removed getAll(), and updated get() to return all values.

Implementation

@JS('get')
external String? mGet(String name);