Saturday, February 14, 2015

Explanations of methods and properties in Dart HttpClient class. With some notes.

Building Dart clients:      Same post as previous one, but with explanations: 
Some notes of Dart HttpClient class for to help implementing, hacking it.  Source:  
https://api.dartlang.org/apidocs/channels/stable/dartdoc-viewer/dart:io.HttpClient
This is meant to serve as notebook..

  client.authenticate;
  Add credentials to be used for authorizing HTTP requests.

set authenticate(Function Future<bool> f(Uri url, String scheme, String realm))
Sets the function to be called when a site is requesting authentication. The URL requested and the security realm from the server are passed in the arguments url and realm.
         The function returns a Future which should complete when the authentication has been resolved. If credentials cannot be provided the Future should complete with false. If credentials are available the function should add these using addCredentials before completing the Future with the value true.

If the Future completes with true the request will be retried using the updated credentials. Otherwise response processing will continue normally.

  client.authenticateProxy;      LONG!!:  
  Add credentials to be used for authorizing HTTP proxies.
set authenticateProxy(Function Future<bool> f(String host, int port, String scheme, String realm))


  client.autoUncompress;      LONG:
  bool autoUncompress     :
Get and set whether the body of a response will be automatically uncompressed.

  client.badCertificateCallback;        LONG:
  client.badCertificateCallback( callback(X509Certificate, String, int) → bool)
set badCertificateCallback(Function bool callback(X509Certificate cert, String host, int port))
Sets a callback that will decide whether to accept a secure connection with a server certificate that cannot be authenticated by any of our trusted root certificates.


  client.findProxy;       Long explanation....
set findProxy(Function String f(Uri url))
static String findProxyFromEnvironment(Uri url, {Map<String, String> environment})
Function for resolving the proxy server to be used for a HTTP connection from the proxy configuration specified through environment variables.
  client.findProxy( f(Uri) → String);

  client.hashCode;
int get hashCode
Inherited from Object.       Get a hash code for this object.

  client.idleTimeout;
Duration idleTimeout  Get and set the idle timeout of non-active persistent (keep-alive) connections. The default value is 15 seconds.


  client.maxConnectionsPerHost;
int maxConnectionsPerHost.  Get and set the maximum number of live connections, to a single host.
Increasing this number may lower performance and take up unwanted system resources.
To disable, set to null.  Default is null.

  client.runtimeType;
Type get runtimeType. Inherited from Object.
A representation of the runtime type of the object.

  client.userAgent;
String userAgent.  Set and get the default value of the User-Agent header for all requests generated by this HttpClient. The default value is Dart/<version> (dart:io).
If the userAgent is set to null, no default User-Agent header will be added to each request.

  client.addCredentials(url, realm, credentials);
void addCredentials(Uri url, String realm, HttpClientCredentials credentials)
Add credentials to be used for authorizing HTTP requests.


  client.addProxyCredentials(host, port, realm, credentials);
void addCredentials(Uri url, String realm, HttpClientCredentials credentials)

Add credentials to be used for authorizing HTTP requests.

  client.close();
Shutdown the HTTP client. If force is false (the default) the HttpClient will be kept alive until all active connections are done. If force is true any active connections will be closed to immediately release all resources. These closed connections will receive an onError callback to indicate that the client was shutdown. In both cases trying to establish a new connection after calling shutdown will throw an exception.

  client.delete(host, port, path);
Future<HttpClientRequest> delete(String host, int port, String path)
Opens a HTTP connection using the DELETE method.
The server is specified using host and port, and the path (including possible fragment and query) is specified using path. See open for details.

  client.deleteUrl(url);
Future<HttpClientRequest> deleteUrl(Uri url)
Opens a HTTP connection using the DELETE method.  The URL to use is specified in url.

  client.get(host, port, path);
Future<HttpClientRequest> get(String host, int port, String path)
Opens a HTTP connection using the GET method.  The server is specified using host and port, and the path (including possible fragment and query) is specified using path.

  client.getUrl(url);
Future<HttpClientRequest> getUrl(Uri url)
Opens a HTTP connection using the GET method.  The URL to use is specified in url.


  client.hashCode;

  client.head(host, port, path);
Future<HttpClientRequest> head(String host, int port, String path)
Opens a HTTP connection using the HEAD method.  The server is specified using host and port, and the path (including possible fragment and query) is specified using path.


  client.headUrl(url);Future<HttpClientRequest> headUrl(Uri url)
Opens a HTTP connection using the HEAD method.   The URL to use is specified in url.

  client.noSuchMethod(invocation);noSuchMethod is invoked when users invoke a non-existent method on an object. The name of the method and the arguments of the invocation are passed to noSuchMethod in an Invocation. If noSuchMethod returns a value, that value becomes the result of the original invocation.
The default behavior of noSuchMethod is to throw a NoSuchMethodError.

  client.open(method, host, port, path)
Future<HttpClientRequest> open(String method, String host, int port, String path)
Opens a HTTP connection.
The HTTP method to use is specified in method, the server is specified using host and port, and the path (including possible fragment and query) is specified using path.
The Host header for the request will be set to the value host:port. This can be overridden through the HttpClientRequest interface before the request is sent. NOTE if host is an IP address this will still be set in the Host header.
For additional information on the sequence of events during an HTTP transaction, and the objects returned by the futures, see the overall documentation for the class HttpClient.

  client.openUrl(method, url);
Future<HttpClientRequest> openUrl(String method, Uri url)
Opens a HTTP connection.  The HTTP method is specified in method and the URL to use in url.
The Host header for the request will be set to the value host:port. This can be overridden through the HttpClientRequest interface before the request is sent. NOTE if host is an IP address this will still be set in the Host header.
For additional information on the sequence of events during an HTTP transaction, and the objects returned by the futures, see the overall documentation for the class HttpClient.

  client.patch(host, port, path);
Future<HttpClientRequest> patch(String host, int port, String path)
Opens a HTTP connection using the PATCH method.  The server is specified using host and port, and the path (including possible fragment and query) is specified using path.

  client.patchUrl(url);
Future<HttpClientRequest> patchUrl(Uri url)
Opens a HTTP connection using the PATCH method.  The URL to use is specified in url.

  client.post(host, port, path)
Future<HttpClientRequest> post(String host, int port, String path)
Opens a HTTP connection using the POST method.  The server is specified using host and port, and the path (including possible fragment and query) is specified using path.

    client.postUrl(url);
Future<HttpClientRequest> postUrl(Uri url)
Opens a HTTP connection using the POST method.   The URL to use is specified in url.


  client.put(host, port, path);
Future<HttpClientRequest> put(String host, int port, String path)
Opens a HTTP connection using the PUT method.  The server is specified using host and port, and the path (including possible fragment and query) is specified using path.

  client.putUrl(url); 
Future<HttpClientRequest> putUrl(Uri url)
Opens a HTTP connection using the PUT method.  The URL to use is specified in url.

  client.toString();
String toString()      Inherited from Object  
Returns a string representation of this object.

And somewhere is meant to put some red-pen markings for this...

No comments:

Post a Comment