locked
WebView & IUriToStreamResolver

    Question

  • I'm trying to feed a WebView with the contents of a zip file, so I implemented an IUriToStreamResolver that turns URIs into bytestreams from the zip file.  

    I get the file path from the URI, seek to that path in the zip archive, and return its IInputStream.  

    While the WebView appears to be getting the expected data and renders it (mostly) correctly, I've noticed that the Content-Length header is ALWAYS 209715200, or exactly 200MB.  

    I expect this happens because the WebView will keep reading the IInputStream until it reaches a special character (EOF), at which it stops reading and returns its count of bytes read as the Content-Length, but for some reason never gets an EOF.  (I'm looking into the behavior of my zip file library to see why.)  It doesn't keep reading to the end of the archive, and the actual returned content in the HTTP response is as expected.

    So, my questions:

     * Does the WebView keep reading until it reaches an EOF like I suspect?  Will adding an EOF character to the end of each archive's stream fix this behavior?

     * Is there a way to specify the expected size of the IInputStream that is returned by the IUriToStreamResolver?

    Update:  I've changed the behavior of the IInputStream that is returned by my StreamResolver to append a Ctrl+Z (ascii 26) when its underlying libzip call (zip_fread) returns -1 or 0, but this doesn't appear to fix the behavior.  ASCII EOT (code 4) also doesn't work.


    • Edited by bdares Friday, October 24, 2014 10:34 PM
    Friday, October 24, 2014 8:42 PM

Answers

  • Hi Bdares,

    Yes, I know you want to retire file stream from zip file without unzip that file because sometimes we just need a small file. I would recommend you try to write your code for this purpose. Or you could send request to MSDN code example to ask for this. Refer to the following page and submit your requirement. https://code.msdn.microsoft.com/site/requests.

     Regards,


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place. Click HERE to participate the survey.

    Tuesday, October 28, 2014 2:52 AM
    Moderator

All replies

  • Hi Bdares,

    According to your description, are you want to retire image content stream from a zip file using IUriToStreamResolver? If so I think you are making things complex. I would recommend you unzip the zip file first into storage and then find the image or other resource files. Here is a post about this topic posted by Matt.

    If I misunderstand you, please post more information or code about your scenario.

    Regards,


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place. Click HERE to participate the survey.

    Monday, October 27, 2014 6:31 AM
    Moderator
  • Hi Herro.

    The reason I want to stream from a zip file is that the zip archive can be large (>300mb), although the individual files I am looking at are typically under 1mb, so unzipping them as a temporary file should work.  It means we're using the filesystem as a buffer for something that was already in memory, but I'll take it for now if it works.

    I still have the lingering question of the behavior of the WebView and how/when it decides that a stream has ended.  It could be that the implementation of IInputStream::ReadAsync that I'm using is incorrectly implemented.

    Monday, October 27, 2014 4:11 PM
  • Hi Bdares,

    Yes, I know you want to retire file stream from zip file without unzip that file because sometimes we just need a small file. I would recommend you try to write your code for this purpose. Or you could send request to MSDN code example to ask for this. Refer to the following page and submit your requirement. https://code.msdn.microsoft.com/site/requests.

     Regards,


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place. Click HERE to participate the survey.

    Tuesday, October 28, 2014 2:52 AM
    Moderator