curl

How to read a GZIP payload in Ruby Sinatra

烂漫一生 提交于 2021-01-28 12:23:10
问题 On a remote host I have a bash script sending a simple gzipped YAML file to my Ruby Sinatra endpoint: #!/bin/bash /bin/gzip -c /tmp/test.yaml > /tmp/test.gz curl -i <hostname>:<port>/last_run_report -H "Content-Type: application/xml" -H "Content-Encoding: gzip" --data-binary @/tmp/test.gz My sample Ruby app is: require 'sinatra' require 'zlib' require 'stringio' set :port, <port> set :bind, "<ip>" post '/last_run_report' do sio = StringIO.new(request.body.to_s) gz = Zlib::GzipReader.new(sio)

Accept cookies with CURL on PHP

て烟熏妆下的殇ゞ 提交于 2021-01-28 11:40:33
问题 I'm trying to run a log in script over my Centos machine. What the script does is logging in with a username and password to a 3rd party site and gets the page contents. Although the script works perfectly in my PC (XAMPP at Windows), in my Centos box it seems not work. After logging in, it keeps redirecting to the log in page (although the log in succeed). Here is the code: function request($url,$post) { $ch = curl_init(); $curlConfig = array( CURLOPT_URL => $url, CURLOPT_POST => 1, CURLOPT

CURL Rest POST endpoint without requestbody

空扰寡人 提交于 2021-01-28 10:52:01
问题 Is there any simple way of curl a REST API POST endpoint without a request body? For some reason, the API i am working with is using a endpoint as POST even though its an obvious GET. No Request or HTTP parameters should be added to the request. The response i get when i do: curl -i -X POST https://APIURL is: <BODY><h2>Length Required</h2> <hr><p>HTTP Error 411. The request must be chunked or have a content length.</p> </BODY> 回答1: Add content-length header with your curl request as it is

Postgresql: How to use curl with function

笑着哭i 提交于 2021-01-28 08:20:22
问题 I have a function parse_sdf(text) . When I call the function like this: INSERT INTO test.table("Id", "Test") (SELECT props -> 'Id', props -> 'Test' FROM parse_sdf()); When I execute the INSERT with pgsql I want to pass as a parameter a text file which I download via curl . Like this: INSERT INTO test.table("Id", "Test") (SELECT props -> 'Id', props -> 'Test' FROM parse_sdf('curl http://test/Files/text.txt')); But it doesn't work. Is there a way to accomplish this? UPDATE: Postgres version: 10

PHP cURL Form data: Multiple variables, same name, diff. values

自闭症网瘾萝莉.ら 提交于 2021-01-28 07:23:28
问题 I am working with PHP cUrl to query a form. It does a POST query, so I am using an associative array. This is what the form looks like: <form action="form.php" method="POST"> ... <input type="hidden" name="var" value="value1"> <input type="hidden" name="var" value="value2"> <input type="hidden" name="var" value="value3"> <input type="hidden" name="var" value="value4"> <input type="hidden" name="var" value="value5"> ... </form> While doing my cUrl query, I have the following code: $postfields

Curl connection refused between applications on Docker container

一笑奈何 提交于 2021-01-28 06:18:29
问题 I have a website (ZF1) and an API (Laravel) running on the same Docker (Laradock) container. I can access each separately through a browser, but when I make a cURL request from the website to the application, I get a null response and the header returns 0. If I output the cURL errors, then I get this: $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, '[API_ENDPOINT]'); curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_HEADER, true); curl_setopt($ch, CURLOPT_FOLLOWLOCATION,

index number to large for python

孤街醉人 提交于 2021-01-28 06:12:04
问题 Hello all I am trying to make an easy json with some data i pull from a type of API. I want the "key" to be one of the ids, however i get the following error "cannot fit 'int' into an index-sized integer". So looking around I think this means that the number I am trying to associate as the key is larger than a number can be?? So I was thinking about some possible work-arounds for this and was wondering if anyone knows a way to get around this. The best thing I can think of is create a

Stripe API - PHP Curl request behind a proxy

断了今生、忘了曾经 提交于 2021-01-28 06:05:39
问题 I'm trying to make a request behind a proxy to stripe api using php and curl. The following works if I'm not behind a proxy: $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, "https://api.stripe.com/v1/balance"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_USERPWD, "$a_pass"); $out = curl_exec($ch); # returns my balance curl_close($ch); A request to any other domain using the proxy works: $username = 'user'; $password =

Failed to connect to testing-3be52.firebaseio.com port 443: Connection refused

北慕城南 提交于 2021-01-28 05:32:35
问题 I am trying to read firebase's data in PHP using cURL. $curl = curl_init(); $url = "https://testing-3be52.firebaseio.com/test-Details.json"; curl_setopt($curl, CURLOPT_URL, $url); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); curl_setopt($curl, CURLOPT_TIMEOUT, 5); curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 5); $result = curl_exec ($curl); $err_status = curl_error($curl); curl_close ($curl); $characters = json_decode($result,true); //...logic goes here to display the data... Above piece of

curl: redirect 302: Not changing the method from POST to GET

拈花ヽ惹草 提交于 2021-01-28 05:10:07
问题 I have a url(/add_item) to which i send data using a POST method. After finishing the task it will redirect to url2 (/show_items) I using the curl command (POST method and also --location is used to auto redirect). The following is the command $ curl --verbose --location --request POST 'http://127.0.0.1:8000/add_item' \ --header 'Content-Type: application/json' \ --data-raw '{ "item" : "new" }' The output Note: Unnecessary use of -X or --request, POST is already inferred. * Trying 127.0.0.1..