gpt4 book ai didi

android - 如何在 Android 中检查请求是 POST 还是 GET

转载 作者:太空狗 更新时间:2023-10-29 15:15:50 27 4
gpt4 key购买 nike

我想检查从网页到 Android 设备的请求,无论是 POST 请求还是 Google Chrome 浏览器中的 GET 请求。请告诉我该怎么做。

enter image description here

注意:我想在任何 WebView 的 Override 方法中进行如下检查。

if request.method == 'GET':
do_something()
elif request.method == 'POST':
do_something_else()

编辑 1: 我尝试登录 Google。我得到如下“POST”。我已经在 Android WebView 上尝试过使用 onFormResubmission 方法。但没有被调用。

@Override
public void onFormResubmission(WebView view, Message dontResend, Message resend) {
super.onFormResubmission(view, dontResend, resend);
}

enter image description here

最佳答案

HttpURLConnection con = (HttpURLConnection) url.openConnection();
String reqMethod = con.getRequestMethod();

这样就可以得到准确的方法

关于android - 如何在 Android 中检查请求是 POST 还是 GET,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12909185/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com