Is it possible to generate equivalent browser URL from all curl request.
Example :
If I am executing following
curl -v -X GET -H "Host:something.com" "http://foo.com/some?appAction=xux&a=1&b=2"
What will corresponding browser URL.(which I can hit directly in browser)
If by "equivalent" you mean "Using a host header claiming a different host than mentioned in the request URI", then the answer is: no, you can't. The browser will pull the host header from the entered URI.
You may be able to rewrite the headers using browser plugins.
Related
I am using curl to connect to an http server which sends back a secure flagged cookie, and I found out that curl doesn't handle such cookies (secure cookies received over http connection), in other words : even using -c cookieFile switch, such cookies are not saved.
A workaround is to use -D switch to save all headers then manually (externally to curl) read the cookie from the file and set it in the curl command to send it back to server.
I want to know if there is a possibility (may be I am missing some curl options) to make curl support such cookies ? I tried to look into curl manual but nothing useful to my use case.
Thanks in advance,
TL;DR: With recent versions of cURL it is no longer possible to save cookies with the secure attribute in conjunction with cookie related switches.
According the documentation cURL removed the ability to save cookies with the secure attribute in order to satisfy the RFC draft draft-ietf-httpbis-cookie-alone-01. This RFC draft mandates that secure cookies are only supposed to be handled, saved or overwritten by an HTTP client if said cookie was transferred over HTTPS.
I just stumbled over the exactly the same problem, so I can offer two alternatives:
use a cURL version before the feature was implemented
cURL < v7.46.0
see respective Github issue which led to this behaviour
dump the headers manually with curl -i or curl -D and extract the cookies
example to save all secure cookies and save them in a file cookies.txt
curl -i http://server.com | grep "Set-Cookie: " | sed 's/Set-Cookie: //g' > cookies.txt
Now, a cookie jar would be useless if you would not use the cookies inside. Especially regarding the second alternative, it may be necessary to remove the Secure attribute in order to make cURL send the saved cookies back to the web server.
I can curl a website URL by passing on some header params. I am trying to get the same result on the browser but I cannot build the URL for the browser in the right way.
My curl looks something similar
curl -X GET -u 'xyz#gmail.com' -H "app-key: some-keys" -H "account-email: procurement#gmail.com" -H 'Content-Type: application/json' -d 'paused=false' https://api.pingdom.com/api/2.1/checks
When prompted for the password, i can give the password and Iget the JSON response.
Now I try to build the same URL on my browser. The browser prompts for user name and password which I have already given.
Now my URL looks like this.
https://api.pingdom.com/api/2.1/users?account-email=procurement#gmail.com&app-key=some-key
I get a forbidden (as JSON reponse) when I try from the browser and from Curl I get the proper JSON response.
How can I add header params to a URL when pinging from the browser?
How can I add header params to a URL when pinging from the browser?
That's not possible. Besides it, from the browser address bar you won't be able to use HTTP methods other than GET.
So I advise you to you proper tools to target/test your Web API such as Postman or Paw.
I'm using "curl -L --post302 -request PUT --data-binary #file " to post a file to a redirected address. At the moment the redirection is not optional since it will allow for signed headers and a new destination. The GET version works well. The PUT version under a certain file size threshold works also. I need a way for the PUT to allow itself to be redirected without sending the file on the first request (to the redirectorURL) and then only send the file when the POST is redirected to a new URL. In other words, I don't want to transfer the same file twice. Is this possible? According to the RFC (https://www.rfc-editor.org/rfc/rfc2616#section-8.2) it appears that a server may send a 100 "with an undeclared wait for 100 (Continue) status, applies only to HTTP/1.1 requests without the client asking to send its payload" so what I'm asking for may be thwarted by the server. Is there a way around this with one curl call? If not, two curl calls?
Try curl -L -T file $URL as the more "proper" way to PUT that file. (Often repeated by me: -X and --request should be avoided if possible, they cause misery.)
curl will use "Expect: 100" by itself in this case, but you'll also probably learn that servers widely don't care about supporting that anyway so it'll most likely still end up having to PUT twice...
I've tried this every which way, but, I cannot seem to get the syntax right (though I can make it work through a website such as hurl.it). I'm trying a basic HTTP POST request with CURL and I need it to do the following:
1.) Be able to do a very basic non-oauth login (username and password) to http://www.fake.site/create
2.) Send over a few HTTP headers such as "Host, Connection, Content-Length, User-Agent, etc."
3.) Be able to pass over 1 parameter in this format {"guid":"","style":"The Style Here"}
4.) Be able to follow a redirect(s)
I would appreciate any assistance you may have--I have literally been to over 5 pages of Google results and I just hit a snag at ever turn with my CURL code.
Help and Thank you!
curl -X POST -L
-u "auth-User:auth-password"
-d "{\"guid\":\"\",\"style\":\"The Style Here\"}"
-H "Content-Type: application/json"
"http://www.fake.site/create"
You can add more headers through -H parameter if you want.
What would the following cURL command look like as a generic (without cURL) http request?
feedUri="https://www.someservice.com/feeds\
?prettyprint=true"
curl $feedUri --silent \
--header "GData-Version: 2"
For example how could such an http request be expressed in the browser address bar? Partucluarly, how do I express the --header information if I were to just type out the plain http request?
I don't know of any browser that lets you specify header information in the address bar. I believe there are plug-ins that let you do this, but I don't have any experience with them.
Here is one for firefox that looks promising:
https://addons.mozilla.org/en-US/firefox/addon/967
Basically what you want to do is not a standard browser feature.