简体   繁体   English

2 相同的 HTTP 请求给出不同的结果?

[英]2 Same HTTP Requests Give Different Results?

What differentiate these 2 requests that cause them to have different results/responses from the server although they should be the same?这两个请求有什么区别,导致它们从服务器获得不同的结果/响应,尽管它们应该是相同的?

  1. Request initiated by Chrome after a simple click/navigation(successful, response code is 302)简单点击/导航后由 Chrome 发起的请求(成功,响应码为 302)
  2. I simply copied that request as a curl and imported it to Postman and then postman hanged我只是将该请求复制为 curl 并将其导入 Postman 然后 postman 挂起

I did the same with Java - HttpUrlConnection(mimicking all the request headers and cookies like Chrome sent), but it hanged and waited forever.我对 Java - HttpUrlConnection(模仿所有请求标头和 cookies 就像 Chrome 发送一样)做了同样的事情,但它挂起并永远等待。 Is this simply because of the server logic that doesn't accept non-browser client?这仅仅是因为服务器逻辑不接受非浏览器客户端吗?

Here are the steps that I tried:以下是我尝试的步骤:

1. Visited this link: https://www.tokopedia.com/p/handphone-tablet/handphone
2. I opened the inspector and opened the Network - All tab
3. I clicked one of the products
4. I clicked the top request from the Network - All tab
5. I copied it as cURL bash
6. I imported it to Postman
7. I ran that request
8. Postman hanged

The only way to be sure that the exact same data is sent is to manually send it yourself through something like telnet.确保发送完全相同的数据的唯一方法是自己通过 telnet 之类的方式手动发送。 I had a similar problem once- it turned out that the browser was sending the data in one big chunk, while my code was sending it line-by-line.我曾经遇到过类似的问题 - 结果是浏览器正在发送一大块数据,而我的代码是逐行发送数据。 No site should have this problem, but it's possible that it exists.没有网站应该有这个问题,但它可能存在。

The server might be checking for User-Agent request header and will block traffic that does not originate from a browser.服务器可能正在检查用户代理请求 header并将阻止不是来自浏览器的流量。 Try setting the header in curl or your Java Code to a value corresponding to (any) browser.尝试将 header 中的curl或您的 Java 代码设置为对应于(任何)浏览器的值。 I've encountered such behavior on some e-shops and commercial websites.我在一些电子商店和商业网站上遇到过这种行为。

Actually the problem might even go deeper than what the other answers say.实际上,问题甚至可能比其他答案所说的更深。

So neither the User-Agent request header nor telnet might solve that problem (unless you initialize the TLS handshake also with telnet MANUALLY, but that is near impossible to complete).因此,用户代理请求 header 和 telnet 都不能解决该问题(除非您也使用 telnet 手动初始化 TLS 握手,但这几乎不可能完成)。

TLS fingerprinting TLS 指纹识别

If the connection is an SSL/TLS connection, the server could detect which algorithm is used to generate keys, and most applications have their specific signature / cipher.如果连接是 SSL/TLS 连接,服务器可以检测使用哪种算法生成密钥,并且大多数应用程序都有其特定的签名/密码。

So only by the TLS handshake alone you can tell Chrome from Postman or FireFox or Java.因此,仅通过 TLS 握手,您就可以从 Postman 或 FireFox 或 Java 中分辨出 Chrome。 Java usually - unless a JVM implementation REALLY wants to go off-road - has the same signature across all platforms, using the same cipher/algorithm across all implementations. Java 通常 - 除非 JVM 实现真的想要 go 越野 - 在所有平台上具有相同的签名,在所有平台上使用相同的密码/算法。

I am sorry I cannot properly recall the name of this technique. 很抱歉,我无法正确回忆这种技术的名称。 The first project I know that published this is called something like "A3" or "S3". 我知道发布的第一个项目称为“A3”或“S3”。 Salesforce published an article about JA3 analysis. Salesforce发表了一篇关于JA3分析的文章。 They describe the technique and show a list of signatures and applications so you can guesstimate what app you're talking to, without the need to even decrypt the data: https://engineering.salesforce.com/tls-fingerprinting-with-ja3-and-ja3s-247362855967他们描述了该技术并显示了签名和应用程序列表,因此您可以猜测您正在与之交谈的应用程序,甚至无需解密数据: https://engineering.salesforce.com/tls-fingerprinting-with-ja3 -and-ja3s-247362855967

My Solution我的解决方案

I had that same problem too, wanted to scan the NVidia or AMD servers for graphics card availability.我也有同样的问题,想扫描 NVidia 或 AMD 服务器的显卡可用性。 Did not work from Java, so after a lot of research, finding the project mentioned above, I simply used Selenium to control FireFox and that got the proper server responses and I achieved my goal this way.从 Java 没有工作,所以经过大量研究,找到上面提到的项目,我只是使用 Selenium 来控制 FireFox 并以这种方式得到了我的目标服务器响应。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Java Random对象可以在同一种子的不同执行中给出不同的结果吗? - Can a Java Random object give different results in different executions for the same seed? 不同的Maven版本提供不同的Pmd结果 - Different Maven versions give different pmd results Files.exists(path)和path.toFile()。exists()为同一文件提供不同的结果 - Files.exists(path) and path.toFile().exists() give different results for the same file 为什么 super.hashCode 对来自同一个 Class 的对象给出不同的结果? - Why does super.hashCode give different results on objects from the same Class? 从相同检查点提取的经过重新训练的Tflite / Pb模型给出不同的结果 - Retrained Tflite/Pb models extracted from the same checkpoint give different results 对png和bmp进行按位运算会得到不同的结果? (相同的32位ARGB表示形式) - Bitwise operations on a png and bmp give different results? (Same 32 bit ARGB representation) 在多个服务器上重播HTTP请求并比较结果 - Replaying HTTP requests on multiple servers and comparing the results 推理没有给出相同的结果* - Reasoning doesn't give same results with * CPLEX启发式算法提供不同的计算结果 - CPLEX heuristics give different computational results weka GUI和Java代码给出不同的结果 - weka GUI and Java code give different results
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM