Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>For some reason, the http response body when requesting that image contains a mime part (mime parts are useful for putting multiple files into a single response). In this response, there is only one mime part, so it is mostly useless.</p> <p>There is code in the javax.mail package that you might be able to use to parse this properly if you want, but it's not a very good api, imho.</p> <p>Alternatively, there are a bunch of ways you could hackishly fix this in code yourself. Since there's only one mime part, you can just throw away data from the beginning of your input stream until you see two newline characters in a row (bytes equal to 10). That should work since mime headers are supposed to be 7-bit ascii, iirc, so there's no character encoding to worry about.</p> <p>Here is some sample code:</p> <pre><code>URLConnection conn = urlNorthView.openConnection(); InputStream in = conn.getInputStream(); String contentType = conn.getHeaderField("Content-Type"); if (!"image/jpeg".equals(contentType)) { // hack: assuming it's mime if not a raw image int one = in.read(); if (one == -1) { // stop?? } int two = in.read(); while (two != -1 &amp;&amp; !(two == 10 &amp;&amp; one == 10)) { one = two; two = in.read(); } } // if it was mime, we've stripped off the mime headers // and should now get the image inputStream2Disk(in); </code></pre> <p>Edit: crap, instead of two \n, you'll see two \r\n, or the bytes 0x0d, 0x0a, 0x0d, 0x0a. Throwing away data until you see this pattern is left as an exercise to the reader ;)</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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. 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