<i id='annGl'><tr id='annGl'><dt id='annGl'><q id='annGl'><span id='annGl'><b id='annGl'><form id='annGl'><ins id='annGl'></ins><ul id='annGl'></ul><sub id='annGl'></sub></form><legend id='annGl'></legend><bdo id='annGl'><pre id='annGl'><center id='annGl'></center></pre></bdo></b><th id='annGl'></th></span></q></dt></tr></i><div id='annGl'><tfoot id='annGl'></tfoot><dl id='annGl'><fieldset id='annGl'></fieldset></dl></div>
    • <bdo id='annGl'></bdo><ul id='annGl'></ul>
  • <small id='annGl'></small><noframes id='annGl'>

  • <legend id='annGl'><style id='annGl'><dir id='annGl'><q id='annGl'></q></dir></style></legend>

    1. <tfoot id='annGl'></tfoot>

        POCO C++ - NET SSL - 如何发布 HTTPS 请求

        时间:2023-09-19
          <tbody id='MTfTt'></tbody>
          • <tfoot id='MTfTt'></tfoot>

              <legend id='MTfTt'><style id='MTfTt'><dir id='MTfTt'><q id='MTfTt'></q></dir></style></legend>
              <i id='MTfTt'><tr id='MTfTt'><dt id='MTfTt'><q id='MTfTt'><span id='MTfTt'><b id='MTfTt'><form id='MTfTt'><ins id='MTfTt'></ins><ul id='MTfTt'></ul><sub id='MTfTt'></sub></form><legend id='MTfTt'></legend><bdo id='MTfTt'><pre id='MTfTt'><center id='MTfTt'></center></pre></bdo></b><th id='MTfTt'></th></span></q></dt></tr></i><div id='MTfTt'><tfoot id='MTfTt'></tfoot><dl id='MTfTt'><fieldset id='MTfTt'></fieldset></dl></div>

              <small id='MTfTt'></small><noframes id='MTfTt'>

                <bdo id='MTfTt'></bdo><ul id='MTfTt'></ul>

                  本文介绍了POCO C++ - NET SSL - 如何发布 HTTPS 请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  如何正确地对 HTTPS 服务器进行 POST 并正确嵌入登录数据.下面的代码不返回任何 cookie(在 Wininet 中是这样).我想知道 POCO HTTP 库如何处理 HTTP 重定向?

                  How to correctly do a POST to HTTPS server and embed the login data correctly. Below code does not return any cookies (in Wininet it does). I wonder how POCO HTTP library handles HTTP redirections?

                  MyApp()
                  {
                      try
                      {
                          const Poco::URI uri( "https://localhost.com" );
                          const Poco::Net::Context::Ptr context( new Poco::Net::Context( Poco::Net::Context::CLIENT_USE, "", "", "rootcert.pem" ) );
                          Poco::Net::HTTPSClientSession session(uri.getHost(), uri.getPort(), context );
                          Poco::Net::HTTPRequest req(Poco::Net::HTTPRequest::HTTP_POST, "/login.php" );
                          req.setContentType("Content-Type: application/x-www-form-urlencoded
                  ");
                          req.setKeepAlive(true);
                  
                          std::string reqBody("username=???&password=???&action_login=Log+In
                  
                  ");
                          req.setContentLength( reqBody.length() );
                  
                          //Poco::Net::HTTPBasicCredentials cred("???", "???");
                          //cred.authenticate(req);
                          session.sendRequest(req) << reqBody;
                          Poco::Net::HTTPResponse res;
                          std::istream& rs = session.receiveResponse(res);
                          std::string resp;
                  
                          std::vector<Poco::Net::HTTPCookie> cookies;
                          res.getCookies( cookies );
                      }
                      catch( const Poco::Net::SSLException& e )
                      {
                          std::cerr << e.what() << ": " << e.message() << std::endl;
                      }
                      catch( const std::exception& e )
                      {
                          std::cerr << e.what() << std::endl;;
                      }
                  
                  };
                  

                  推荐答案

                  您正在像这样设置内容类型:

                  You are setting content type like this:

                  req.setContentType("Content-Type: application/x-www-form-urlencoded
                  ");
                  

                  应该是:

                  req.setContentType("application/x-www-form-urlencoded
                  ");
                  

                  这篇关于POCO C++ - NET SSL - 如何发布 HTTPS 请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:仿射变换、简单旋转和缩放或其他完全不同的东 下一篇:更改静态链接 DLL 的 DLL 搜索路径

                  相关文章

                  最新文章

                  <i id='Vae8G'><tr id='Vae8G'><dt id='Vae8G'><q id='Vae8G'><span id='Vae8G'><b id='Vae8G'><form id='Vae8G'><ins id='Vae8G'></ins><ul id='Vae8G'></ul><sub id='Vae8G'></sub></form><legend id='Vae8G'></legend><bdo id='Vae8G'><pre id='Vae8G'><center id='Vae8G'></center></pre></bdo></b><th id='Vae8G'></th></span></q></dt></tr></i><div id='Vae8G'><tfoot id='Vae8G'></tfoot><dl id='Vae8G'><fieldset id='Vae8G'></fieldset></dl></div>

                  <small id='Vae8G'></small><noframes id='Vae8G'>

                  <legend id='Vae8G'><style id='Vae8G'><dir id='Vae8G'><q id='Vae8G'></q></dir></style></legend>

                1. <tfoot id='Vae8G'></tfoot>
                  • <bdo id='Vae8G'></bdo><ul id='Vae8G'></ul>