如何解析多部分 HttpWebResponse
我完全不知道如何解析这个多部分的 httpresponse。这是我收到的格式:
MIME-Version: 1.0
RETS-Version: RETS/1.8
RETS-Server: Interealty-RETS/1.5.247.0
Transfer-Encoding: chunked
Cache-Control: private,private, max-age=0
Date: Sun, 25 Sep 2011 00:45:51 GMT
Set-Cookie: ASP.NET_SessionId=jt11w155vitdtlnwt2p3l345; path=/; HttpOnly,RETS-Session-ID=jt11w155vitdtlnwt2p3l345; path=/
Server: Microsoft-IIS/6.0
X-AspNet-Version: 2.0.50727
Content-Type: multipart/parallel; boundary=yz2C9C5D87FD6148a3986510BCACF917A82C9C5D87FD6148a3986510BCACF917A8ZY
--simple boundary
Content-Type: image/jpeg
Content-ID: 123456
Object-ID: 1
<binary data>
--simple boundary
Content-Type: image/jpeg
Content-ID: 123457
Object-ID: 1
<binary data>
如何隔离响应的不同部分?这将返回一堆图像。我需要做的是将二进制数据转换为图像(我可以做到)并将其以 Content-ID +“-”+ Object-ID +“.jpg”的格式保存到磁盘。我知道如何将字节转换为图像,我只是不知道如何隔离字节以便我可以转换它。任何帮助和示例代码将不胜感激!
I'm completely lost on how to parse this multipart httpresponse. This is the format that I receive:
MIME-Version: 1.0
RETS-Version: RETS/1.8
RETS-Server: Interealty-RETS/1.5.247.0
Transfer-Encoding: chunked
Cache-Control: private,private, max-age=0
Date: Sun, 25 Sep 2011 00:45:51 GMT
Set-Cookie: ASP.NET_SessionId=jt11w155vitdtlnwt2p3l345; path=/; HttpOnly,RETS-Session-ID=jt11w155vitdtlnwt2p3l345; path=/
Server: Microsoft-IIS/6.0
X-AspNet-Version: 2.0.50727
Content-Type: multipart/parallel; boundary=yz2C9C5D87FD6148a3986510BCACF917A82C9C5D87FD6148a3986510BCACF917A8ZY
--simple boundary
Content-Type: image/jpeg
Content-ID: 123456
Object-ID: 1
<binary data>
--simple boundary
Content-Type: image/jpeg
Content-ID: 123457
Object-ID: 1
<binary data>
How can I isolate the different parts of the response? This is returning a bunch of images. What I need to do is convert the binary data into the image (which i can do) and save it to the disk in the format Content-ID + "-" + Object-ID + ".jpg". I know how to convert the bytes into the image, i just don't know how to isolate the bytes so i can convert it. Any help and example code would be much appreciated!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我最终使用一个库来解析 RETS(房地产交易标准)响应。我使用的库名为 librets。
I ended up using a library to parse the RETS (Real Estate Transaction Standard) responses. The library I used was called librets.
我建议您使用像 RestSharp 这样的库。
I recommend you use a library like RestSharp.
如果您尝试使用 RETS 协议下载房地产交易,请尝试使用 http://code.google。 com/p/jrets/
If you are trying to download real estate transactions using the RETS protocol, try using http://code.google.com/p/jrets/