Browse Source

update with most recent slides

gh-pages
Brett Langdon 12 years ago
parent
commit
0d0c0165fa
3 changed files with 358 additions and 14 deletions
  1. +126
    -14
      index.html
  2. +5
    -0
      remark-0.6.4.min.js
  3. +227
    -0
      slides.md

+ 126
- 14
index.html View File

@ -31,6 +31,15 @@
float: left; float: left;
width:33%; width:33%;
} }
h1 {
margin-top: 0;
padding-top: .1em;
margin-bottom: .1em;
padding-bottom: .1em;
}
ul{
margin-top: .2em;
}
</style> </style>
</head> </head>
<body> <body>
@ -39,7 +48,7 @@ class: center,middle
# cURL # cURL
### [brettlangdon](http://brett.is) | [Shapeways](https://www.shapeways.com) ### [brettlangdon](http://brett.is) | [Shapeways](https://www.shapeways.com)
http://brettlangdon.github.io/curl-talk
http://brettlangdon.github.io/curl-talk
--- ---
@ -54,8 +63,8 @@ Supported Protocols:
* FTP * FTP
* FTPS * FTPS
* GOPHER * GOPHER
* HTTP
* HTTPS]
* **HTTP**
* **HTTPS**]
.float-block[ .float-block[
* IMAP * IMAP
* IMAPS * IMAPS
@ -100,14 +109,15 @@ Connection: close
* `-h` - __Help:__ Show all CLI options * `-h` - __Help:__ Show all CLI options
* `-F CONTENT` - __Form Data:__ Add Multipart Form data to request * `-F CONTENT` - __Form Data:__ Add Multipart Form data to request
* `-H HEADER` - __Header:__ Add HEADER to request header * `-H HEADER` - __Header:__ Add HEADER to request header
* `-X COMMAND` - __Method:__ Which request method to use (GET/POST/etc)
* `-X COMMAND` - __Method:__ Set request method (GET/POST/etc)
* `-o FILE` - __Output:__ Output to FILE rather than stdout * `-o FILE` - __Output:__ Output to FILE rather than stdout
* `-L` - __Follow Redirects:__ Follow all redirects * `-L` - __Follow Redirects:__ Follow all redirects
* `-i` - __Response Headers:__ Show the requests response headers
--- ---
# Download a File # Download a File
### Download to stdout
```bash ```bash
$ curl http://www.google.com $ curl http://www.google.com
<!doctype html><html itemscope="" <!doctype html><html itemscope=""
@ -116,16 +126,16 @@ lang="en"><head>
... ...
``` ```
### Save to a File
### Save to a File "google-home.html"
```bash ```bash
$ curl -o google.com http://www.google.com
$ curl -o google-home.html http://www.google.com
``` ```
--- ---
# Response Headers Only # Response Headers Only
* `-I` - Show response headers _ONLY_
```bash ```bash
$ curl -I http://www.google.com $ curl -I http://www.google.com
HTTP/1.1 200 OK HTTP/1.1 200 OK
@ -133,8 +143,8 @@ Date: Sat, 26 Apr 2014 20:40:04 GMT
Expires: -1 Expires: -1
Cache-Control: private, max-age=0 Cache-Control: private, max-age=0
Content-Type: text/html; charset=ISO-8859-1 Content-Type: text/html; charset=ISO-8859-1
Set-Cookie: PREF=ID=61629e9495553921:FF=0:TM=1398544804:LM=...
Set-Cookie: NID=67=HHSAgTCIZ3zd6w2hjrNqoX1VX9NDaqscV9YckpI2...
Set-Cookie: PREF=ID=61629e9495553921:FF=0:TM=1398544804...
Set-Cookie: NID=67=HHSAgTCIZ3zd6w2hjrNqoX1VX9NDaqscV9Yc...
P3P: CP="This is not a P3P policy! See ..." P3P: CP="This is not a P3P policy! See ..."
Server: gws Server: gws
X-XSS-Protection: 1; mode=block X-XSS-Protection: 1; mode=block
@ -146,9 +156,11 @@ Transfer-Encoding: chunked
--- ---
# Save/Reuse Cookies # Save/Reuse Cookies
* `-c FILE` - Save cookies to _FILE_
* `-b FILE` - Load cookies from _FILE_
```bash ```bash
$ curl -c cookies http://www.google.com
$ curl -c cookies -b cookies http://www.google.com
$ cat cookies $ cat cookies
# Netscape HTTP Cookie File # Netscape HTTP Cookie File
# http://curl.haxx.se/docs/http-cookies.html # http://curl.haxx.se/docs/http-cookies.html
@ -156,11 +168,111 @@ $ cat cookies
ID=bec963a425f5d8ca:FF=0:TM=1398545024:LM=1398545024:S=... ID=bec963a425f5d8ca:FF=0:TM=1398545024:LM=1398545024:S=...
67=BV0jhMokci-G3ZbOJ2UeFaNX1faFdfbFVcPHYIpAh35Uz2th6lVq... 67=BV0jhMokci-G3ZbOJ2UeFaNX1faFdfbFVcPHYIpAh35Uz2th6lVq...
# resuse stored cookies
$ curl -c cookies -b cookies http://www.google.com
```
---
# Following Redirects
* `-I` - Response headers only
* `-L` - Follow redirects
```bash
$ curl -I -L http://google.com
HTTP/1.1 301 Moved Permanently
Location: http://www.google.com/
...
Expires: Sat, 31 May 2014 12:50:05 GMT
Cache-Control: public, max-age=2592000
HTTP/1.1 200 OK
Date: Thu, 01 May 2014 12:50:05 GMT
Expires: -1
Cache-Control: private, max-age=0
Content-Type: text/html; charset=ISO-8859-1
...
```
---
# HTTP POST Data
* `-X METHOD` - Set HTTP Request Method
* `-d DATA` - Send request form data
```bash
$ curl -X POST -d "name=brett&talk=curl" http://httpbin.org/post
{
"form": {
"name": "brett",
"talk": "curl"
},
"headers": {
"Host": "httpbin.org",
"Content-Type": "application/x-www-form-urlencoded",
...
},
...
}
```
---
# HTTP POST File
* `-d @FILE` - Send _FILE_ with the request
* `-X METHOD` - Set HTTP request method
* `-H HEADER` - Add _HEADER_ to request headers
```bash
$ cat data.json
{"name": "brett","talk": "curl"}
$ curl -X POST -d @data.json \
-H "Content-Type: application/json" http://httpbin.org/post
{
"data": "{\"name\": \"brett\",\"talk\": \"curl\"}",
"json": {
"talk": "curl",
"name": "brett"
},
"headers": {
"Content-Type": "application/json",
...
}
```
---
# HTTPS
```bash
$ curl https://www.google.com
<!doctype html><html itemscope=""
itemtype="http://schema.org/WebPage"
lang="en"><head>
...
```
#### Allow Insecure Certs
* `-k` - Allow Insecure Certs
```bash
$ curl -k https://insecure-site.gov
```
---
# Learning More
* cURL Website
* http://curl.haxx.se/
* This talk
* http://brettlangdon.github.io/curl-talk
* httpbin (test http request/response)
* http://httpbin.org/
```bash
$ man curl
$ curl --help
``` ```
</textarea> </textarea>
<script src="http://gnab.github.io/remark/downloads/remark-0.6.4.min.js" type="text/javascript">
<script src="./remark-0.6.4.min.js" type="text/javascript">
</script> </script>
<script type="text/javascript"> <script type="text/javascript">
var slideshow = remark.create({ var slideshow = remark.create({


+ 5
- 0
remark-0.6.4.min.js
File diff suppressed because it is too large
View File


+ 227
- 0
slides.md View File

@ -0,0 +1,227 @@
class: center,middle
# cURL
### [brettlangdon](http://brett.is) | [Shapeways](https://www.shapeways.com)
http://brettlangdon.github.io/curl-talk
---
# What is cURL?
CLI tool for getting/sending files via URL's
Supported Protocols:
.float-block[
* DICT
* FILE
* FTP
* FTPS
* GOPHER
* **HTTP**
* **HTTPS**]
.float-block[
* IMAP
* IMAPS
* LDAP
* LDAPS
* POP3
* POP3S
* RTMP]
.float-block[
* RTSP
* SCP
* SFTP
* SMTP
* SMTPS
* TELNET
* TFTP]
---
# Quick Examples
```bash
$ curl http://icanhazip.com
108.46.182.85
$ curl -i http://icanhazip.com
HTTP/1.1 200 OK
Date: Sat, 26 Apr 2014 19:49:57 GMT
Server: Apache
Content-Length: 14
Content-Type: text/plain; charset=UTF-8
Connection: close
108.46.182.85
```
---
# Useful CLI Arguments
* `-v` - __Verbose:__ Make cURL more talkative
* `-h` - __Help:__ Show all CLI options
* `-F CONTENT` - __Form Data:__ Add Multipart Form data to request
* `-H HEADER` - __Header:__ Add HEADER to request header
* `-X COMMAND` - __Method:__ Set request method (GET/POST/etc)
* `-o FILE` - __Output:__ Output to FILE rather than stdout
* `-L` - __Follow Redirects:__ Follow all redirects
* `-i` - __Response Headers:__ Show the requests response headers
---
# Download a File
### Download to stdout
```bash
$ curl http://www.google.com
<!doctype html><html itemscope=""
itemtype="http://schema.org/WebPage"
lang="en"><head>
...
```
### Save to a File "google-home.html"
```bash
$ curl -o google-home.html http://www.google.com
```
---
# Response Headers Only
* `-I` - Show response headers _ONLY_
```bash
$ curl -I http://www.google.com
HTTP/1.1 200 OK
Date: Sat, 26 Apr 2014 20:40:04 GMT
Expires: -1
Cache-Control: private, max-age=0
Content-Type: text/html; charset=ISO-8859-1
Set-Cookie: PREF=ID=61629e9495553921:FF=0:TM=1398544804...
Set-Cookie: NID=67=HHSAgTCIZ3zd6w2hjrNqoX1VX9NDaqscV9Yc...
P3P: CP="This is not a P3P policy! See ..."
Server: gws
X-XSS-Protection: 1; mode=block
X-Frame-Options: SAMEORIGIN
Alternate-Protocol: 80:quic
Transfer-Encoding: chunked
```
---
# Save/Reuse Cookies
* `-c FILE` - Save cookies to _FILE_
* `-b FILE` - Load cookies from _FILE_
```bash
$ curl -c cookies -b cookies http://www.google.com
$ cat cookies
# Netscape HTTP Cookie File
# http://curl.haxx.se/docs/http-cookies.html
# This file was generated by libcurl! Edit at your own risk.
ID=bec963a425f5d8ca:FF=0:TM=1398545024:LM=1398545024:S=...
67=BV0jhMokci-G3ZbOJ2UeFaNX1faFdfbFVcPHYIpAh35Uz2th6lVq...
```
---
# Following Redirects
* `-I` - Response headers only
* `-L` - Follow redirects
```bash
$ curl -I -L http://google.com
HTTP/1.1 301 Moved Permanently
Location: http://www.google.com/
...
Expires: Sat, 31 May 2014 12:50:05 GMT
Cache-Control: public, max-age=2592000
HTTP/1.1 200 OK
Date: Thu, 01 May 2014 12:50:05 GMT
Expires: -1
Cache-Control: private, max-age=0
Content-Type: text/html; charset=ISO-8859-1
...
```
---
# HTTP POST Data
* `-X METHOD` - Set HTTP Request Method
* `-d DATA` - Send request form data
```bash
$ curl -X POST -d "name=brett&talk=curl" http://httpbin.org/post
{
"form": {
"name": "brett",
"talk": "curl"
},
"headers": {
"Host": "httpbin.org",
"Content-Type": "application/x-www-form-urlencoded",
...
},
...
}
```
---
# HTTP POST File
* `-d @FILE` - Send _FILE_ with the request
* `-X METHOD` - Set HTTP request method
* `-H HEADER` - Add _HEADER_ to request headers
```bash
$ cat data.json
{"name": "brett","talk": "curl"}
$ curl -X POST -d @data.json \
-H "Content-Type: application/json" http://httpbin.org/post
{
"data": "{\"name\": \"brett\",\"talk\": \"curl\"}",
"json": {
"talk": "curl",
"name": "brett"
},
"headers": {
"Content-Type": "application/json",
...
}
```
---
# HTTPS
```bash
$ curl https://www.google.com
<!doctype html><html itemscope=""
itemtype="http://schema.org/WebPage"
lang="en"><head>
...
```
#### Allow Insecure Certs
* `-k` - Allow Insecure Certs
```bash
$ curl -k https://insecure-site.gov
```
---
# Learning More
* cURL Website
* http://curl.haxx.se/
* This talk
* http://brettlangdon.github.io/curl-talk
* httpbin (test http request/response)
* http://httpbin.org/
```bash
$ man curl
$ curl --help
```

Loading…
Cancel
Save