Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>the HEAD operation, as defined by the HTTP standard does not return any content apart from the header information. So if you are sending a head request, you could only inspect the MIME type of the file from the HTTP response header.</p> <p>The header information can be obtained by looking at the Representation returned from wrapping it into a ClientResource and performing a head request. This gives you a high level interface to the HTTP transport and you don't need to do custom header parsing.</p> <pre><code>ClientResource resource = new ClientResource(url); Representation representation = resource.head(); representation.getMediaType(); // returns the Media Type </code></pre> <p>If you want to do content type guessing on the actual content of the file, you would need to download the actual content, for example with a GET request against that resource.</p> <p>Or in true REST fashion you could model an extra query parameter for your resource which would return your custom meta information for that file, e.g.</p> <pre><code>http://server/file?contentType </code></pre> <p>In similar fashion, to retrieve the actual content, you could get a handle on the Stream and then do your encoding guessing.</p> <pre><code>Representation representation = resource.get(); InputStream stream = representation.getStream(); </code></pre> <p>To specify ranges, if supported by the server, you can set the ranges, before submitting your get request.</p> <pre><code>List&lt;Range&gt; ranges = new ArrayList&lt;Range&gt;(); ranges.add(new Range(0,100)); // this would request the first 100 bytes resource.setRanges(ranges); Representation representation = resource.get(); </code></pre> <p>Make sure you consume the response (stream) completely, before returning.</p> <p>I suggest you would look into other efforts which help you determining the content type. Like here <a href="https://stackoverflow.com/questions/457655/java-charset-and-windows/457849#457849">Java charset and Windows</a> Or <a href="http://glaforge.free.fr/wiki/index.php?wiki=GuessEncoding" rel="nofollow noreferrer">http://glaforge.free.fr/wiki/index.php?wiki=GuessEncoding</a></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload