Curl

From NovaOrdis Knowledge Base
Revision as of 18:43, 4 January 2017 by Ovidiu (talk | contribs) (Created page with "=Internal= * Linux * wget !!!Download a file and write it locally {{{ curl -O http://ftp.gnu.org/gnu/wget/wget-1.15.tar.gz }}} !!!Send REST invoca...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Internal


!!!Download a file and write it locally

{{{ curl -O http://ftp.gnu.org/gnu/wget/wget-1.15.tar.gz }}}


!!!Send REST invocations

!!GET


{{{

curl -X GET http://localhost:8080/amgen-paas/project/

}}}

!!!POST

{{{

curl -H "Content-Type: application/json" -X POST \

 -d '{"id":"1","name":"MyProject","team":"A","language":"java","size":"small"}' \
 http://localhost:8080/amgen-paas/project/MyProject

}}}


!!!PUT

{{{

curl -X PUT -d arg=val -d arg=val http://localhost:8080/amgen-paas/project/MyProject

}}}

!!!DELETE

{{{

curl -X DELETE http://localhost:8080/amgen-paas/project/MyProject

}}}

!!!Command Line Configuration

!!-X

The HTTP method.

!!-H

Specifies a request header. Multiple headers can be specified. Example:

{{{ curl -H "Authentication Bearer: <token>" -H "Content-Type: application/json" ... }}}

!Content-Type

{{{

    -H "Content-Type: application/json"

}}}

!!-u

Authentication:

{{{ curl -u username:password }}}

!!-k --insecure

Insecure.

!!-v

Verbose. Shows more details about the request and response. A line starting with '>' means "header data" sent by curl, '<' means "header data" received by curl that is hidden in normal cases, and a line starting with '*' means additional info provided by curl.

!!-i

Show the HTTP headers in the output.

!!-A

Specify the User-Agent string to send to the HTTP server. To encode blanks in the string, surround the string with single quote marks. This can also be set with the -H header option. If this option is used several times, the last one will be used.

!!-d <data>

Sends the specified data in a POST request to the HTTP server, in the same way that a browser does when a user has filled in an HTML form and presses the submit button. This will cause curl to pass the data to the server using the content-type application/x-www-form-urlencoded.

If the option is used more than once on the same command line, the data pieces specified will be merged together with a separating &-symbol. Thus, using "-d name=alice -d qualification=coder" would generate a post chunk that looks like 'name=alice&qualification=coder'.

If data starts with the letter @, the rest should be a file name to read the data from, or - if you want curl to read the data from stdin. Multiple files can also be specified. When --data is told to read from a file like that, carriage returns and newlines will be stripped out. If you don't want the @ character to have a special interpretation use --data-raw instead.


!-d and GET

If -d is used with GET, the data is sent as a [entity-body|HTTP#HTTPRequestEntityBody].

!!-I

HEAD only.

!!!Simulation of a HTTP Session JSessionID

{{{ curl -b "JSESSIONID=e1VBIIBFhyjU2PLU0JFNwqYu" http://localhost:8080/session-servlet/ }}}


__Referenced by:__\\ [{INSERT com.ecyrd.jspwiki.plugin.ReferringPagesPlugin WHERE max=20, maxwidth=50}]