Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android脚本打印response.body后数据被截断 #304

Closed
mdikjse opened this issue Sep 3, 2024 · 21 comments
Closed

Android脚本打印response.body后数据被截断 #304

mdikjse opened this issue Sep 3, 2024 · 21 comments
Assignees
Labels
bug Something isn't working done 已经完成 p1 工作清单首位的高度优先问题

Comments

@mdikjse
Copy link

mdikjse commented Sep 3, 2024

描述错误(Describe the bug)
安卓端抓取某网站时验证码图片数据response.body被打印后数据变短了,只有头部9字节数据了
To Reproduce
重现行为的步骤: 如具体应用抓包失败,请说明软件名称以及具体操作页面
请求这个网址http://xxpt.scxfks.com/study/captcha
不开脚本打印日志正常,开了脚本只打印了一个日志就导致返回数据Content-Length只有9
*屏幕截图(Screenshots)
Screenshot_20240903_222632_com network proxy
Screenshot_20240903_221809_com network proxy_edit_150604291659831
Screenshot_20240903_221752_com network proxy_edit_150616007412434

@mdikjse mdikjse added the bug Something isn't working label Sep 3, 2024
@wanghongenpin
Copy link
Owner

现在body都转换成字符串了,对于字节格式会出现数据不一致问题,我在考虑要不要提供个rawBody只读字段, 表示二进制,需要修改字节还是改 body,我会判断修改的body字段是二进制还是字符串

@mdikjse
Copy link
Author

mdikjse commented Sep 3, 2024

现在body都转换成字符串了,对于字节格式会出现数据不一致问题,我在考虑要不要提供个rawBody只读字段, 表示二进制,需要修改字节还是改 body,我会判断修改的body字段是二进制还是字符串

为什么不打印就不会出错呢?是不是链式调用body就会处理成字符串?如果是这样的话可以考虑修改body的调用,让其在赋值操作时再转换,未赋值操作则使用只读方式返回,不知道这样会不会好一点

@mdikjse
Copy link
Author

mdikjse commented Sep 3, 2024

现在body都转换成字符串了,对于字节格式会出现数据不一致问题,我在考虑要不要提供个rawBody只读字段, 表示二进制,需要修改字节还是改 body,我会判断修改的body字段是二进制还是字符串

刚刚试了下,好像不修改也不行,应该是内部强制转换了body的问题。

@mdikjse
Copy link
Author

mdikjse commented Sep 3, 2024

//http response
HttpResponse convertHttpResponse(HttpResponse response, Map<dynamic, dynamic> map) {
response.headers.clear();
response.status = HttpStatus.valueOf(map['statusCode']);
map['headers'].forEach((key, value) {
if (value is List) {
response.headers.addValues(key, value.map((e) => e.toString()).toList());
return;
}

  response.headers.add(key, value);
});
response.headers.remove(HttpHeaders.CONTENT_ENCODING);

//判断是否是二进制
if (getListElementType(map['body']) == int) {
  response.body = convertList<int>(map['body']);
  return response;
}

response.body = map['body'] == null ? null : utf8.encode(map['body'].toString());
return response;

}
这是已经改了么

@DuckBurnIncense
Copy link

//http response
HttpResponse convertHttpResponse(HttpResponse response, Map<dynamic, dynamic> map) {
response.headers.clear();
response.status = HttpStatus.valueOf(map['statusCode']);
map['headers'].forEach((key, value) {
if (value is List) {
response.headers.addValues(key, value.map((e) => e.toString()).toList());
return;
}

  response.headers.add(key, value);
});
response.headers.remove(HttpHeaders.CONTENT_ENCODING);

//判断是否是二进制
if (getListElementType(map['body']) == int) {
  response.body = convertList<int>(map['body']);
  return response;
}

response.body = map['body'] == null ? null : utf8.encode(map['body'].toString());
return response;

}
这是已经改了么

并没有,// 判断是否是二进制 是上个月的 commit 95c01c3 提交的。(好巧啊,我也遇到了该问题,刚才也在翻源码看是啥导致的该问题呢)

@mdikjse
Copy link
Author

mdikjse commented Sep 3, 2024

//http response
HttpResponse convertHttpResponse(HttpResponse response, Map<dynamic, dynamic> map) {
response.headers.clear();
response.status = HttpStatus.valueOf(map['statusCode']);
map['headers'].forEach((key, value) {
if (value is List) {
response.headers.addValues(key, value.map((e) => e.toString()).toList());
return;
}

  response.headers.add(key, value);
});
response.headers.remove(HttpHeaders.CONTENT_ENCODING);

//判断是否是二进制
if (getListElementType(map['body']) == int) {
  response.body = convertList<int>(map['body']);
  return response;
}

response.body = map['body'] == null ? null : utf8.encode(map['body'].toString());
return response;

}
这是已经改了么

并没有,// 判断是否是二进制 是上个月的 commit 95c01c3 提交的。(好巧啊,我也遇到了该问题,刚才也在翻源码看是啥导致的该问题呢)

这不巧了吗。。。明天继续看源码😂

@wanghongenpin
Copy link
Owner

那个是根据content-type对视频和图片做了处理,你这个content-type都没有返回

@wanghongenpin wanghongenpin self-assigned this Sep 13, 2024
@wanghongenpin wanghongenpin added the p1 工作清单首位的高度优先问题 label Sep 13, 2024
@wanghongenpin
Copy link
Owner

V1.1.3版本已经处理, 如果需要原始字节数组,访问rawBody字段
https://github.com/wanghongenpin/network_proxy_flutter/releases/tag/V1.1.3

@wanghongenpin wanghongenpin added the done 已经完成 label Sep 15, 2024
@mdikjse
Copy link
Author

mdikjse commented Sep 15, 2024

大佬辛苦了,感谢!

@mdikjse
Copy link
Author

mdikjse commented Sep 15, 2024

V1.1.3版本已经处理, 如果需要原始字节数组,访问rawBody字段 https://github.com/wanghongenpin/network_proxy_flutter/releases/tag/V1.1.3

大佬,请求重写好像用不了啦

@mdikjse mdikjse closed this as completed Sep 15, 2024
@mdikjse mdikjse reopened this Sep 15, 2024
@wanghongenpin
Copy link
Owner

怎么用不了?

大佬,请求重写好像用不了啦

@mdikjse
Copy link
Author

mdikjse commented Sep 15, 2024

我是从1.1.2升级的,然后设置都没改,请求重写没法用了

@mdikjse
Copy link
Author

mdikjse commented Sep 15, 2024

怎么用不了?

大佬,请求重写好像用不了啦

大佬你测试下看看,我也正在测试,我重新安装之前的版本再试试看

@wanghongenpin
Copy link
Owner

正在打包,稍等

大佬你测试下看看,我也正在测试,我重新安装之前的版本再试试看

@mdikjse
Copy link
Author

mdikjse commented Sep 15, 2024

正在打包,稍等

大佬你测试下看看,我也正在测试,我重新安装之前的版本再试试看

我测试完之前的再测试看你改了的有没有问题

@mdikjse
Copy link
Author

mdikjse commented Sep 15, 2024

正在打包,稍等

大佬你测试下看看,我也正在测试,我重新安装之前的版本再试试看

大佬,测试确实1.1.2可以的,1.1.3重写修改不行了

@wanghongenpin
Copy link
Owner

最新的包我测试可以了

@mdikjse
Copy link
Author

mdikjse commented Sep 15, 2024

最新的包我测试可以了

大佬我测试了还是不行,我看了抓到的包变了,但是微信页面没问题,软件里面我看抓到的包中文乱码了
下面是1.1.3抓的包
Uploading Screenshot_20240915_231725_com.network.proxy.jpg…

下面是1.1.2抓的包
Uploading Screenshot_20240915_232843.jpg…
奇怪,传不了图了

@wanghongenpin
Copy link
Owner

wanghongenpin commented Sep 15, 2024

content-type是什么

@mdikjse
Copy link
Author

mdikjse commented Sep 15, 2024

content-type是什么

Screenshot_20240915_233811_com network proxy

@mdikjse
Copy link
Author

mdikjse commented Sep 15, 2024

content-type是什么

大佬你在QQ群里没

@mdikjse mdikjse closed this as completed Sep 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working done 已经完成 p1 工作清单首位的高度优先问题
Projects
None yet
Development

No branches or pull requests

3 participants