I'm trying to understand how this system is working under the hood. The system is REST
based which is pretty standard, what I don't get the client makes a OPTIONS
call before each API call and XML content is returned in the format. It's using Jersey Java.
OPTIONS
response for the DELETE
method
Access-Control-Request-Method: DELETE
is passed in the headers
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<application xmlns="http://wadl.dev.java.net/2009/02">
<doc xmlns:jersey="http://jersey.java.net/" jersey:generatedBy="Jersey: 2.8 2014-04-29 01:25:26"/>
<grammars/>
<resources base=“http://example.com”>
<resource path=“data/gasdfasdg/entity”>
<method id="deleteEntity" name="DELETE">
<request>
<param xmlns:xs="http://www.w3.org/2001/XMLSchema" type="xs:string"/>
</request>
<response>
<representation mediaType="application/json"/>
</response>
</method>
<method id="getOneEntitysMetadata" name="GET">
<request>
<param xmlns:xs="http://www.w3.org/2001/XMLSchema" name="q" style="query" type="xs:string"/>
<param xmlns:xs="http://www.w3.org/2001/XMLSchema" name="x-dps-compute-content-size" style="header" type="xs:boolean"/>
<param xmlns:xs="http://www.w3.org/2001/XMLSchema" type="xs:string"/>
</request>
<response>
<representation mediaType="application/json"/>
</response>
</method>
<method id="createOrUpdateEntity" name="PUT">
<request>
<param xmlns:xs="http://www.w3.org/2001/XMLSchema" type="xs:string"/>
</request>
<response>
<representation mediaType="application/json"/>
</response>
</method>
</resource>
</resources>
</application>
Questions:
A. Is it a standard or industry practice for client to call OPTIONS
first, process, and analyze the response and determine the API, parameters etc. before making an actual call? Earlier I've been just looking at docs and programming my REST calls in client (JavaScript) accordingly.
B. Is this call made by browser automatically (preflight) or was it programmed in the client?