HalosGhost / pbpst

A command-line libcurl C client for pb deployments
GNU General Public License v2.0
44 stars 9 forks source link

pbpst does not work with stdin #89

Open winny- opened 6 years ago

winny- commented 6 years ago

Related

Output

➜  pbpst git:(master) ✗ ./dist/pbpst -S < Makerules 
pbpst: Could not create paste: HTTP response code said error
pbpst: Removed empty swap file (contingency)

I get this error with commit ecbe08a0b72a6e4212f09fc6cf52a73506992346 & version 1.4.0.

Verbose output

➜  pbpst git:(master) ✗ pbpst -SVVV < Makerules
*   Trying 138.197.7.107...
* TCP_NODELAY set
*   Trying 2604:a880:800:a1::78b:2001...
* TCP_NODELAY set
* Immediate connect fail for 2604:a880:800:a1::78b:2001: Cannot assign requested address
* Connected to ptpb.pw (138.197.7.107) port 443 (#0)
* ALPN, offering http/1.1
* successfully set certificate verify locations:
*   CAfile: /etc/ssl/certs/ca-certificates.crt
  CApath: none
* SSL connection using TLSv1.2 / ECDHE-RSA-AES128-GCM-SHA256
* ALPN, server accepted to use http/1.1
* Server certificate:
*  subject: CN=ptpb.pw
*  start date: Nov 17 05:20:15 2017 GMT
*  expire date: Feb 15 05:20:15 2018 GMT
*  subjectAltName: host "ptpb.pw" matched cert's "ptpb.pw"
*  issuer: C=US; O=Let's Encrypt; CN=Let's Encrypt Authority X3
*  SSL certificate verify ok.
> POST / HTTP/1.1
Host: ptpb.pw
Transfer-Encoding: chunked
Accept: application/json
Content-Type: multipart/form-data; boundary=------------------------d45bb2bbc47a2fec
Expect: 100-continue

< HTTP/1.1 100 Continue
* Signaling end of chunked upload via terminating chunk.
* The requested URL returned error: 400 BAD REQUEST
* stopped the pause stream!
* Closing connection 0
pbpst: Could not create paste: HTTP response code said error
pbpst: Removed empty swap flie (contingency)
winny- commented 6 years ago

Oops, just realized this is probably a duplicate of #86. TL;DR pb doesn't support Transfer-Encoding: chunked, and returns a 400 HTTP error. It appears curl cli tool implemented a fix as mentioned in the above Related issue.

This is how they fixed it curl/curl@665b3e48bc95713ecceaddf445fc2049440a6fb3

HalosGhost commented 6 years ago

Indeed, this is a duplicate of #86, but this investigation along with a proposed fix is incredibly helpful. Thank you for looking through it! I will see if I can't get the fix setup this weekend.

winny- commented 6 years ago

No problem! I kept on running into this bug for months and chalked it up to some strange sort of user error.

I do not believe this is directly related, but curl_formadd has been deprecated.

rafasc commented 6 years ago

Is there any updates on this?

HalosGhost commented 6 years ago

I'm afraid not quite yet. I've been swamped with life lately. I have some of the progress on switching over to curl_mime on the branch in this repo of the same name. But, I have not yet gotten it working.

buhman commented 6 years ago

Keeping in mind it involves a rewrite, (werkzeug/flask/wsgi are never going to fix this), I think explicitly requesting API support for chunked transfers of unknown total size is completely valid, particularly if it results in a cleaner pbpst implementation.