【发布时间】:2014-01-11 12:51:32
【问题描述】:
我正在使用 ServerXMLHTTP 和 HTTPRequester 插件发送请求,我可以看到我的请求的响应是请求文件的原始二进制数据。 我需要读取此二进制数据并将其保存在 Byte[] 中,但我不断收到错误消息: 当前编码处于无效状态的文件末尾。
这是我的代码:
ServerXMLHTTP HTTPRequest=new ServerXMLHTTP();
HTTPRequest.open("POST",@"https://thetargetwebsite/",false);
HTTPRequest.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
HTTPRequest.send("file_id=" + file_id);
string binaryfile=HTTPRequest.responseText; // causes the error
//OR
System.Text.UTF8Encoding encoding = new System.Text.UTF8Encoding();
byte[] bytes = encoding.GetBytes(HTTPRequest.responseText); // also causes the error
你能帮我看看如何用二进制数据读取响应文本吗?
编辑: 如果我不使用 ServerXMLHTTP,我应该使用什么来代替?
【问题讨论】:
标签: encoding binary response serverxmlhttp