C ++ Schannel POST 400错误代码错误请求

问题描述 投票:-2回答:1

出于某种原因,我不知道POST请求无效。我很确定问题出在POST字符串"POST /profile.php HTTP/1.1\r\nid=2323\r\nContent-Length: \r\n\r\n"上。 GET请求正常运行,但POST请求无效。

我使用TLS VER 1.0通过端口443连接到服务器

这里是我从服务器获得的错误代码。编辑:我正在尝试编辑此帖子以对其进行修复,它告诉我我的帖子主要是代码,但我希望不再是。

85 bytes of data sent

HTTP/1.1 400 Bad Request
Content-Type: text/html; charset=utf-8
Date: Fri, 22 Nov 2019 06:56:20 GMT
Connection: close
Content-Length: 2959

<!DOCTYPE html>
<html lang="en" id="facebook">
  <head>
    <title>Facebook | Error</title>
    <meta charset="utf-8">
    <meta http-equiv="cache-control" content="no-cache">
    <meta http-equiv="cache-control" content="no-store">
    <meta http-equiv="cache-control" content="max-age=0">
    <meta http-equiv="expires" content="-1">
    <meta http-equiv="pragma" content="no-cache">
    <meta name="robots" content="noindex,nofollow">
    <style>
      html, body {
        color: #141823;
        background-color: #e9eaed;
        font-family: Helvetica, Lucida Grande, Arial,
                     Tahoma, Verdana, sans-serif;
        margin: 0;
        padding: 0;
        text-align: center;
      }

      #header {
        height: 30px;
        padding-bottom: 10px;
        padding-top: 10px;
        text-align: center;
      }

      #icon {
        width: 30px;
      }

      h1 {
        font-size: 18px;
      }

      p {
        font-size: 13px;
      }

      #footer {
        border-top: 1px solid #ddd;
        color: #9197a3;
        font-size: 12px;
        padding: 5px 8px 6px 0;
      }
    </style>
  </head>
  <body>
    <div id="header">
      <a href="//www.facebook.com/">
        <img id="icon" src="//static.facebook.com/images/logos/facebook_2x.png" />
      </a>
    </div>
    <div id="core">
      <h1 id="sorry">Sorry, something went wrong.</h1>
      <p id="promise">
        We're working on it and we'll get it fixed as soon as we can.
      </p>
      <p id="back-link">
        <a id="back" href="//www.facebook.com/">Go Back</a>
      </p>
      <div id="footer">
        Facebook
        <span id="copyright">
          &copy; 2019
        </span>
        <span id="help-link">
          &#183;
          <a id="help" href="//www.facebook.com/help/">Help Center</a>
        </span>
      </div>
    </div>
    <script>
      document.getElementById('back').onclick = function() {
        if (history.length > 1) {
          history.back();
          return false;
        }
      };

      // Adjust the display based on the window size
      if (window.innerHeight < 80 || window.innerWidth < 80) {
        // Blank if window is too small
        document.body.style.display = 'none';
      };
      if (window.innerWidth < 200 || window.innerHeight < 150) {
        document.getElementById('back-link').style.display = 'none';
        document.getElementById('help-link').style.display = 'none';
      };
      if (window.innerWidth < 200) {
        document.getElementById('sorry').style.fontSize = '16px';
      };
      if (window.innerWidth < 150) {
        document.getElementById('promise').style.display = 'none';
      };
      if (window.innerHeight < 150) {
        document.getElementById('sorry').style.margin = '4px 0 0 0';
        document.getElementById('sorry').style.fontSize = '14px';
        document.getElementById('promise').style.display = 'none';
      };
    </script>
  </body>
</html>


3215 bytes received
c++ network-programming winsock sspi schannel
1个回答
0
投票

代替发出POST请求,您可以只使用GET请求并执行此操作

"GET /profile.php?id=2323 HTTP/1.1\r\nConnection: close\r\n\r\n"

主要取决于您要连接的服务器,因此,如果这不起作用,请尝试使用HTTP v1.0

"GET /profile.php?id=2323 HTTP/1.0\r\nConnection: close\r\n\r\n"

如果仍然不起作用,则可能必须指定主机,主要是在您尝试从看起来像https://en30.picwebsite.com的网站上获取图像时>

"GET /profile.php?id=2323 HTTP/1.1\r\nHost: en30.picwebsite.com\r\nConnection: close\r\n\r\n"

同时尝试HTTP v1.0和v1.1

如果所有方法均无效,请确保您正在使用SSL / TLS进行连接。如果您愿意,请尝试使用一个简单的主页GET请求"GET / HTTP/1.1\r\nConnection: close\r\n\r\n"以及HTTP v1.0和v1.1

如果还是不行,那可能是您的Socket / TLS实现或服务器出现问题。

© www.soinside.com 2019 - 2024. All rights reserved.