VC6 curl https post 发json返回问题

用vc6,curl库进行https的post请求发送json数据,我访问的网址是https的,需要通过VPN连接上的,返回如下:
HTTP/1.1 400 Bad Request
返回::HTTP/1.1 400 Bad Request
Server: nginx
Date: Sat, 21 Oct 2017 10:20:10 GMT
Content-Type: text/html;charset=utf-8
Content-Length: 968
Connection: keep-alive

Apache Tomcat/6.0.37 - Error report<!--H1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} H2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} H3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} B {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} P {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A {color : black;}A.name {color : black;}HR {color : #525D76;}-->

HTTP Status 400 -


type Status report

message

description The request sent by the client was syntactically incorrect.


Apache Tomcat/6.0.37

请知道的大神给个解决办法。

摘自百度百科的关于“400(http状态码)”的介绍。

400是一种是HTTP状态码,400 Bad Request。是在打开网页时浏览器返回到客户端的一种状态码。显示在客户端的也就是400页面。
400页面是当用户在打开网页时,返回给用户界面带有400提示符的页面。其含义是你访问的页面域名不存在或者请求错误。
主要有两种形式:
1、bad request意思是“错误的请求";
2、invalid hostname意思是"不存在的域名”。 

所以有可能是你组织url数据的时候出错了,导致400错误出现。提供个排错思路:
1. 用wireshark抓下包,找出你用curl发出的包;
2. 确认包的内容是不是你所设想的格式、内容;
3. 如果是你所设想的那样子,看是否能放在浏览器中访问(浏览器URL似乎只支持GET方式)
4. 在浏览器中不能访问的话,那就先拼凑数据,最终目标:能在浏览器中访问,然后分析浏览器发出的数据包,再用curl组织自己包
5.浏览器能访问的话,可以分析下发送方式,比方说post、get等

这块我也不大熟, 只能说是个人的一些排错思路吧

最终要是解决了,@下我,共同学习下~

我访问的是https网址,但须登录VPN才能访问的,而且是不带证书的,我是post方式发送的json数据,请看看我的代码,如下:

int CHttpClient::Postss(const std::string & strUrl, const std::string & strPost, std::string & strResponse)

{

CURLcode res;

curl_global_init(CURL_GLOBAL_ALL);

CURL* curl = curl_easy_init();  
if(NULL == curl)  
{  
    return CURLE_FAILED_INIT;  
}  

// 设置http发送的内容类型为JSON   
struct curl_slist *headers=NULL;
headers = curl_slist_append(headers,  "Content-Type:application/json;charset=UTF-8");
//headers = curl_slist_append(headers,  "Accpect:application/json;charset=UTF-8");
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);  

if(m_bDebug)  
{  
     curl_easy_setopt(curl, CURLOPT_VERBOSE, 1);  
     curl_easy_setopt(curl, CURLOPT_DEBUGFUNCTION, OnDebug);  

}

//curl_easy_setopt(curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); 

curl_easy_setopt(curl, CURLOPT_URL, strUrl.c_str());  
  //curl_easy_setopt(curl, CURLOPT_URL, "https://10.63.82.51:10443/emm/services/commonCard/makeCardPreValidate.ajax");
curl_easy_setopt(curl, CURLOPT_POST, 1);  
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, strPost.c_str()); //发送json数据 
curl_easy_setopt(curl, CURLOPT_READFUNCTION, NULL);  
  curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, OnWriteData);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void *)&strResponse);//  strResponse,返回数据
curl_easy_setopt(curl, CURLOPT_NOSIGNAL, 1); 

  curl_easy_setopt(curl, CURLOPT_HEADER, 1); 

 curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, false);  
 curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, false);  

curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT, 5);  
curl_easy_setopt(curl, CURLOPT_TIMEOUT, 5);  

//char error1[CURL_ERROR_SIZE]={'\0'};
//curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, error1);

res = curl_easy_perform(curl);  
curl_easy_cleanup(curl);  
return res;  

}