# Class webdriver.http.CorsClient

code »

All implemented interfaces:
  `webdriver.http.Client`

Communicates with a WebDriver server, which may be on a different domain, using the cross-origin resource sharing (CORS) extension to WebDriver's JSON wire protocol.

Each command from the standard JSON protocol will be encoded in a JSON object with the following form: {method:string, path:string, data:!Object}

The encoded command is then sent as a POST request to the server's /xdrpc endpoint. The server will decode the command, re-route it to the appropriate handler, and then return the command's response as a standard JSON response object. The JSON responses will always be returned with a 200 response from the server; clients must rely on the response's "status" field to determine whether the command succeeded.

This client cannot be used with the standard wire protocol due to limitations in the various browser implementations of the CORS specification:

- IE's XDomainRequest object is only capable of generating the types of requests that may be generated through a standard HTML form - it can not send DELETE requests, as is required in the wire protocol.
- WebKit's implementation of CORS does not follow the spec and forbids redirects: https://bugs.webkit.org/show_bug.cgi?id=57600 This limitation appears to be intentional and is documented in WebKit's Layout tests: //LayoutTests/http/tests/xmlhttprequest/access-control-and-redirects.html
- If the server does not return a 2xx response, IE and Opera's implementations will fire the XDomainRequest/XMLHttpRequest object's onerror handler, but without the corresponding response text returned by the server. This renders IE and Opera incapable of handling command failures in the standard JSON protocol.

## Constructor

webdriver.http.CorsClient ( url )

Parameters
url: `string` URL for the WebDriver server to send commands to.

Show:Public Protected Private

## Instance Methods

code »send ( request, callback )

Parameters
request callback

## Instance Properties

code »url_ : `string`

## Static Functions

code »webdriver.http.CorsClient.isAvailable ( ) ⇒ `boolean`

Tests whether the current environment supports cross-origin resource sharing.

Returns
Whether cross-origin resource sharing is supported.

## Static Properties

code »webdriver.http.CorsClient.XDRPC_ENDPOINT : `string`

Resource URL to send commands to on the server.