-
-
Couldn't load subscription status.
- Fork 6.9k
Description
Hi,
I did this
Source
I'm working on a program that communicate to a webservice. This program should send some creating informations like that :
// url : QString, data: QByteArray
mCurlPtr = CurlPtr(curl_easy_init());
curl_easy_setopt(mCurlPtr.get(), CURLOPT_WRITEFUNCTION, GsNetwork::writeCallback);
curl_easy_setopt(mCurlPtr.get(), CURLOPT_WRITEDATA, &mReadBuffer);
curl_easy_setopt(mCurlPtr.get(), CURLOPT_URL, url.toStdString().c_str());
curl_easy_setopt(mCurlPtr.get(), CURLOPT_POST, 1L);
curl_easy_setopt(mCurlPtr.get(), CURLOPT_POSTFIELDSIZE, (long)strlen(QString::fromAscii(data).toStdString().c_str()));
curl_easy_setopt(mCurlPtr.get(), CURLOPT_POSTFIELDS, QString::fromAscii(data).toStdString().c_str());
CURLcode myRes = curl_easy_perform(mCurlPtr.get());
/* Check for errors */
if(myRes != CURLE_OK)
fprintf(stderr, "curl_easy_perform() failed: %s\n",
curl_easy_strerror(myRes)); //I never go here :)
Displaying in C++ debug QString::fromAscii(data).toStdString().c_str() write : "sensorId=1&maxValue=40&minValueNotification=0&maxValueNotification=0"
In my PHP, (I use Apache 2.4 and php Slim Framework V3), I display in log my parameters, and I get :
[Mon Jun 06 07:08:27.340541 2016] [:error] [pid 19870] [client ::1:42937] PARAMETERS :
[Mon Jun 06 07:08:27.340862 2016] [:error] [pid 19870] [client ::1:42937] []
Libcurl DEBUG
"foo=bar&technology=ZWAVE&moduleId=77&name=SES%20302" <---- My parameters encoded
* Found bundle for host localhost: 0xb3006478
* Re-using existing connection! (#0) with host localhost
* Connected to localhost (::1) port 80 (#0)
> POST /api/modules HTTP/1.1
Host: localhost
Accept: */*
Content-Length: 51
Content-Type: application/x-www-form-urlencoded
* upload completely sent off: 51 out of 51 bytes <----- Parameters length is good
< HTTP/1.1 400 Bad Request
< Date: Mon, 06 Jun 2016 07:22:39 GMT
* Server Apache/2.4.10 (Raspbian) is not blacklisted
< Server: Apache/2.4.10 (Raspbian)
< Set-Cookie: PHPSESSID=0fh5gte88cqq39agoisrdi0io0; path=/
< Expires: Thu, 19 Nov 1981 08:52:00 GMT
< Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
< Pragma: no-cache
< Content-Length: 65
< Connection: close
< Content-Type: application/json;charset=utf-8
<
* Closing connection 0
{"status":400,"data":{"msg":"Parameter 'technology' is missing"}} <---- PHP response
I expected the following
The maddly thing is that sometimes, it works (Parameters are send without problem) and sometimes not.
I expected that parameters are send all the time.
curl/libcurl version
My version :
curl 7.38.0 (arm-unknown-linux-gnueabihf) libcurl/7.38.0 OpenSSL/1.0.1k zlib/1.2.8 libidn/1.29 libssh2/1.4.3 librtmp/2.3
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtmp rtsp scp sftp smtp smtps telnet tftp
Features: AsynchDNS IDN IPv6 Largefile GSS-API SPNEGO NTLM NTLM_WB SSL libz TLS-SRP
operating system
I'm on Banana PI M1+, Debian 8.0 with Linux bananapi 3.4.108 #2 SMP PREEMPT armv7l GNU/Linux (up to date).
UPDATE
- Have a good day is missing ;)
- Libcurl provides from :
libcurl4-gnutls-devdebian package