SlideShare a Scribd company logo
1 of 44
Download to read offline
cURL

                  ( )




2011-09-12(   )
curl
                    - transfer a URL
                  • curl is a tool to transfer data from
                    or to a server, using one of the
                    supported protocols (DICT, FILE,
                    FTP, FTPS, GOPHER, HTTP,
                    HTTPS, IMAP, IMAPS, LDAP,
                    LDAPS, POP3, POP3S, RTMP, RTSP,
                    SCP, SFTP, SMTP, SMTPS, TELNET
                    and TFTP).


2011-09-12(   )
why cURL is useful?




                  • curl -O http://example.com/
                   wallpapers/img[01-19].jpg

2011-09-12(   )
why cURL is useful
                  for Web Developers




2011-09-12(   )
HTTP

              $ telnet www.google.co.jp 80
              Trying 74.125.153.105...
              Connected to www.l.google.com.
              Escape character is '^]'.

              GET / HTTP/1.1
              Host: www.google.co.jp

              <   >


2011-09-12(   )
GET / HTTP/1.1


         [method] [request-uri] HTTP/1.1




2011-09-12(   )
2011-09-12(   )
Host: www.google.co.jp


                   Host: <   >




2011-09-12(   )
HTTP

              $ telnet www.google.co.jp 80
              Trying 74.125.153.105...
              Connected to www.l.google.com.
              Escape character is '^]'.

              GET / HTTP/1.1
              Host: www.google.co.jp

              <   >


2011-09-12(   )
curl
              $ curl -v http://www.google.co.jp
              * About to connect() to www.google.co.jp port 80
              (#0)
              *    Trying 74.125.153.106... connected*
              Connected to www.google.co.jp (74.125.153.106)
              port 80 (#0)
              > GET / HTTP/1.1
              > User-Agent: curl/7.21.7 ...
              > Host: www.google.co.jp
              > Accept: */*
              >
              < HTTP/1.1 200 OK
              < Date: Thu, 08 Sep 2011 06:47:44 GMT
              < Expires: -1
              < Cache-Control: private, max-age=0

2011-09-12(   )
curl --head
                     curl --verbose|-v

                  (curl --trace-ascii dump)



2011-09-12(   )
HTTP Header

              $ curl -v http://www.google.co.jp
              *   (ry)
              >   GET / HTTP/1.1
              >   User-Agent: curl/7.21.7 ...
              >   Host: www.google.co.jp
              >   Accept: */*
              >
              <   HTTP/1.1 200 OK
              <   Date: Thu, 08 Sep 2011 06:47:44 GMT
              <   Expires: -1
              <   Cache-Control: private, max-age=0




2011-09-12(   )
HTTP Request Headers
                  Accept

                  Accept-Language

                  Authorization

                  Host

                  Referer

                  User-Agent


2011-09-12(   )
$ curl -v -H 'Accept-Language: ja'
                 http://twitter.com |
                nokogrep -a content 'meta[name=description]'

              > GET / HTTP/1.1
              > User-Agent: curl/7.21.7
              > Host: twitter.com
              > Accept: */*
              > Accept-Language: ja
              >
              < HTTP/1.1 200 OK
              ...




2011-09-12(   )
$ curl -v -H 'Accept-Language: en'
                 http://twitter.com |
                nokogrep -a content 'meta[name=description]'

              > GET / HTTP/1.1
              > User-Agent: curl/7.21.7
              > Host: twitter.com
              > Accept: */*
              > Accept-Language: en
              >
              < HTTP/1.1 200 OK
              ...

              Instantly connect to what's most important to
              you. Follow your friends, experts, favorite
              celebrities, and breaking news.



2011-09-12(   )
$ curl -v 
                     -H 'Accept: application/json' 
                     http://jobs.dev/jobs | 
               ruby -rpp -rjson -e 'pp JSON.parse(STDIN.read)'

              >   GET /jobs HTTP/1.1
              >   User-Agent: curl/7.21.7
              >   Host: jobs.dev
              >   Accept: application/json




2011-09-12(   )
< HTTP/1.1 200 OK
              < Content-Type: application/json; charset=utf-8
              < X-UA-Compatible: IE=Edge
              < ETag: "1490b2d47b09a5abb92bd7eb09c4c51e"
              < Cache-Control:
                 max-age=0, private, must-revalidate
              < X-Runtime: 0.059816
              < Connection: keep-alive
              < Transfer-Encoding: chunked

              [{"created_at"=>"2011-09-07T05:56:22Z",
                "deadline"=>"2011-09-07",
                "description"=>"               !!!",
                  "id"=>1,
                  "public"=>true,
                  "title"=>"10         ",
                  "updated_at"=>"2011-09-07T09:59:33Z"}]


2011-09-12(   )
HTTP Response
              HTTP/1.1 200 OK
              Date: Mon, 12 Sep 2011 01:27:34 GMT
              Server: hi
              Status: 200 OK
              ETag: "ceedd0ac4f0339411aab820e225afcdf"
              Content-Type: text/html; charset=utf-8
              Content-Length: 44188
              Pragma: no-cache
              Expires: Tue, 31 Mar 1981 05:00:00 GMT
              Cache-Control: no-cache, no-store, must-
                 revalidate, pre-check=0, post-check=0
              X-XSS-Protection: 1; mode=block

2011-09-12(   )
HTTP Response
              HTTP/1.1 200 OK
              Date: Mon, 12 Sep 2011 01:27:34 GMT
              Server: hi
              Status: 200 OK
              ETag: "ceedd0ac4f0339411aab820e225afcdf"
              Content-Type: text/html; charset=utf-8
              Content-Length: 44188
              Pragma: no-cache
              Expires: Tue, 31 Mar 1981 05:00:00 GMT
              Cache-Control: no-cache, no-store, must-
                 revalidate, pre-check=0, post-check=0
              X-XSS-Protection: 1; mode=block

2011-09-12(   )
Status line
                  200

                  302

                  400

                  404

                  500

                  503


2011-09-12(   )
HTTP Status is app UI



                   200

                                   404 ?

                   410(Gone)


2011-09-12(   )
HTTP Response Headers
                   Location

                   Server



                   Content-Type

                   Content-Length



                   Expire, ETag, Cache-Control


2011-09-12(   )
curl --data|-d




2011-09-12(   )
POST via curl
      $ curl -v
             -d email=moro@example.jp 
             -d password=hogehoge 
             http://example.com/users

      POST /users HTTP/1.1
      User-Agent: curl/7.21.7
      Host: example.com
      Accept: */*
      Content-Length: 36
      Content-Type:
             application/x-www-form-urlencoded

2011-09-12(   )
HTTP/1.1 201 Created
  Content-Type: application/json
  Date: Mon, 12 Sep 2011 01:43:41 GMT
  Server: journey/0.4.0
  Content-Length: 71
  Connection: keep-alive

  {"email":"moro@example.jp","_id":"4e6d63cd981
  5710100000005","profiles":[]}



2011-09-12(   )
curl --user|-u




2011-09-12(   )
HTTP Authentication

      $ curl -v
             -u moro@example.jp:hogehoge 
             http://example.com/account

      GET /account HTTP/1.1
      Authorization:
          Basic bW9yb0BleGFtcGxlLmpwOmhvZ2Vob2dl
      User-Agent: curl/7.21.7
      Host: example.com
      Accept: */*



2011-09-12(   )
HTTP Authentication

      HTTP/1.1 200 OK
      Content-Type: application/json
      Date: Mon, 12 Sep 2011 01:51:00 GMT
      Server: journey/0.4.0
      Content-Length: 71
      Connection: keep-alive

      {"email":"moro@example.jp","_id":"4e6d63cd9
      815710100000005","profiles":[]}



2011-09-12(   )
cookie
                    &
                   cURL
                    http://flic.kr/p/5ekGdX
2011-09-12(   )
cookie

                  • HTTP              {Cookie}
                                  Web




                       http://www.studyinghttp.net/cookies
2011-09-12(   )
[res] Set-Cookie
                      [req] Cookie


                  • Netscape
                       Set-Cookie      Cookie          2
                    HTTP




                        http://www.studyinghttp.net/cookies#HeadersForCookie

2011-09-12(   )
2011-09-12(   )
2011-09-12(   )
curl --cookie|-b




2011-09-12(   )
without cookie


      $ curl -q http://jobs.dev |
        nokogrep '#header p.greeting'

                  Who are you?
                  Sign in




2011-09-12(   )
Cookie & cURL
      $ curl -v
             -b '_jobs_session=BAh7CEkiD3Nl(      )'
                    http://jobs.dev |
              nokogrep '#header p.greeting'

      GET / HTTP/1.1
      User-Agent: curl/7.21.7
      Host: jobs.dev
      Accept: */*
      Cookie: _jobs_session=BAh7CEkiD3Nl(     )


2011-09-12(   )
Cookie & cURL
      HTTP/1.1 200 OK
      Content-Type: text/html; charset=utf-8
      X-UA-Compatible: IE=Edge
      ETag: "8c0c63144925e4cc29b655906c221a3f"
      Set-Cookie:_jobs_session=BAh7CEkiD3Nl( )
      X-Runtime: 0.156343
      Connection: keep-alive
      Transfer-Encoding: chunked

                  Hi moro@example.jp
                  Sign out


2011-09-12(   )
2011-09-12(   )
$ curl -v 
                     -d 'user[email]=moro@example.jp'
                     -d 'user[password]=hogehoge'
                   http://jobs.dev/users/sign_in

              POST /users/sign_in HTTP/1.1
              User-Agent: curl/7.21.7
              Host: jobs.dev
              Accept: */*
              Content-Length: 51
              Content-Type:
                    application/x-www-form-urlencoded




2011-09-12(   )
HTTP/1.1 302 Moved Temporarily
              Location: http://jobs.dev/
              Content-Type: text/html; charset=utf-8
              X-UA-Compatible: IE=Edge
              Cache-Control: no-cache
              Set-Cookie: _jobs_session=BAh7CE( )
              X-Runtime: 0.217055
              Connection: keep-alive
              Transfer-Encoding: chunked

              <html><body>You are being <a
              href="http://jobs.dev/">redirected</
              a>.</body></html>




2011-09-12(   )
$ curl -v 
                     -b '_jobs_session=BAh7CE(    )'
                    http://jobs.dev/ |
                  nokogrep '#header p.greeting'

              GET / HTTP/1.1
              User-Agent: curl/7.21.7
              Host: jobs.dev
              Accept: */*
              Cookie: _jobs_session=BAh7CE(   )




2011-09-12(   )
HTTP/1.1 200 OK
              Content-Type: text/html; charset=utf-8
              X-UA-Compatible: IE=Edge
              ETag: "98d16875bdceb8c5451e7706e6071ece"
              Cache-Control:
                 max-age=0, private, must-revalidate
              Set-Cookie: _jobs_session=BAh7CUki( )
              X-Runtime: 0.193951
              Connection: keep-alive
              Transfer-Encoding: chunked

                      Hi moro@example.jp
                      Sign out


2011-09-12(   )
2011-09-12(   )
see also

                  • http://www.studyinghttp.net/
                  • http://www.studyinghttp.net/
                   rfc_ja/rfc2616
                  • http://amazon.jp/dp/
                   4774142042/morodiary05-22/
                   ref=nosim/



2011-09-12(   )

More Related Content

What's hot

HTTP colon slash slash: the end of the road?
HTTP colon slash slash: the end of the road?HTTP colon slash slash: the end of the road?
HTTP colon slash slash: the end of the road?Alessandro Nadalin
 
Efficient HTTP Apis
Efficient HTTP ApisEfficient HTTP Apis
Efficient HTTP ApisAdrian Cole
 
Socket programming with php
Socket programming with phpSocket programming with php
Socket programming with phpElizabeth Smith
 
LogStash - Yes, logging can be awesome
LogStash - Yes, logging can be awesomeLogStash - Yes, logging can be awesome
LogStash - Yes, logging can be awesomeJames Turnbull
 
HTTP Caching in Web Application
HTTP Caching in Web ApplicationHTTP Caching in Web Application
HTTP Caching in Web ApplicationMartins Sipenko
 
Varnish Cache and Django (Falcon, Flask etc)
Varnish Cache and Django (Falcon, Flask etc)Varnish Cache and Django (Falcon, Flask etc)
Varnish Cache and Django (Falcon, Flask etc)Данил Иванов
 
I got 99 problems, but ReST ain't one
I got 99 problems, but ReST ain't oneI got 99 problems, but ReST ain't one
I got 99 problems, but ReST ain't oneAdrian Cole
 
HTTP 완벽가이드- 13 다이제스트 인증
HTTP 완벽가이드- 13 다이제스트 인증HTTP 완벽가이드- 13 다이제스트 인증
HTTP 완벽가이드- 13 다이제스트 인증박 민규
 
Ethernet Shield
Ethernet ShieldEthernet Shield
Ethernet ShieldTinker
 
Realtime Communication Techniques with PHP
Realtime Communication Techniques with PHPRealtime Communication Techniques with PHP
Realtime Communication Techniques with PHPWaterSpout
 
Scrip queue tree
Scrip queue treeScrip queue tree
Scrip queue treeMarco Arias
 
Http capturing
Http capturingHttp capturing
Http capturingEric Ahn
 
DEF CON 27- ALBINOWAX - http desync attacks
DEF CON 27- ALBINOWAX - http desync attacksDEF CON 27- ALBINOWAX - http desync attacks
DEF CON 27- ALBINOWAX - http desync attacksFelipe Prado
 
Varnish: Making eZ Publish sites fly
Varnish: Making eZ Publish sites flyVarnish: Making eZ Publish sites fly
Varnish: Making eZ Publish sites flyPeter Keung
 
RestMQ - HTTP/Redis based Message Queue
RestMQ - HTTP/Redis based Message QueueRestMQ - HTTP/Redis based Message Queue
RestMQ - HTTP/Redis based Message QueueGleicon Moraes
 

What's hot (20)

HTTP colon slash slash: the end of the road?
HTTP colon slash slash: the end of the road?HTTP colon slash slash: the end of the road?
HTTP colon slash slash: the end of the road?
 
Efficient HTTP Apis
Efficient HTTP ApisEfficient HTTP Apis
Efficient HTTP Apis
 
Socket programming with php
Socket programming with phpSocket programming with php
Socket programming with php
 
LogStash - Yes, logging can be awesome
LogStash - Yes, logging can be awesomeLogStash - Yes, logging can be awesome
LogStash - Yes, logging can be awesome
 
mod_perl 2.0 For Speed Freaks!
mod_perl 2.0 For Speed Freaks!mod_perl 2.0 For Speed Freaks!
mod_perl 2.0 For Speed Freaks!
 
HTTP Caching in Web Application
HTTP Caching in Web ApplicationHTTP Caching in Web Application
HTTP Caching in Web Application
 
Varnish Cache and Django (Falcon, Flask etc)
Varnish Cache and Django (Falcon, Flask etc)Varnish Cache and Django (Falcon, Flask etc)
Varnish Cache and Django (Falcon, Flask etc)
 
tdc2012
tdc2012tdc2012
tdc2012
 
I got 99 problems, but ReST ain't one
I got 99 problems, but ReST ain't oneI got 99 problems, but ReST ain't one
I got 99 problems, but ReST ain't one
 
HTTP 완벽가이드- 13 다이제스트 인증
HTTP 완벽가이드- 13 다이제스트 인증HTTP 완벽가이드- 13 다이제스트 인증
HTTP 완벽가이드- 13 다이제스트 인증
 
Ethernet Shield
Ethernet ShieldEthernet Shield
Ethernet Shield
 
Restfs internals
Restfs internalsRestfs internals
Restfs internals
 
Realtime Communication Techniques with PHP
Realtime Communication Techniques with PHPRealtime Communication Techniques with PHP
Realtime Communication Techniques with PHP
 
Node.js - A Quick Tour II
Node.js - A Quick Tour IINode.js - A Quick Tour II
Node.js - A Quick Tour II
 
Scrip queue tree
Scrip queue treeScrip queue tree
Scrip queue tree
 
Http capturing
Http capturingHttp capturing
Http capturing
 
Puppet
PuppetPuppet
Puppet
 
DEF CON 27- ALBINOWAX - http desync attacks
DEF CON 27- ALBINOWAX - http desync attacksDEF CON 27- ALBINOWAX - http desync attacks
DEF CON 27- ALBINOWAX - http desync attacks
 
Varnish: Making eZ Publish sites fly
Varnish: Making eZ Publish sites flyVarnish: Making eZ Publish sites fly
Varnish: Making eZ Publish sites fly
 
RestMQ - HTTP/Redis based Message Queue
RestMQ - HTTP/Redis based Message QueueRestMQ - HTTP/Redis based Message Queue
RestMQ - HTTP/Redis based Message Queue
 

Viewers also liked

curl and new technologies
curl and new technologiescurl and new technologies
curl and new technologiesDaniel Stenberg
 
Internet all the things - curl everywhere!
Internet all the things - curl everywhere!Internet all the things - curl everywhere!
Internet all the things - curl everywhere!Daniel Stenberg
 
HTTP/2 - for TCP/IP Geeks Stockholm
HTTP/2 - for TCP/IP Geeks StockholmHTTP/2 - for TCP/IP Geeks Stockholm
HTTP/2 - for TCP/IP Geeks StockholmDaniel Stenberg
 
주로사용되는 Xss필터와 이를 공격하는 방법
주로사용되는 Xss필터와 이를 공격하는 방법주로사용되는 Xss필터와 이를 공격하는 방법
주로사용되는 Xss필터와 이를 공격하는 방법guestad13b55
 
Docker Architecture (v1.3)
Docker Architecture (v1.3)Docker Architecture (v1.3)
Docker Architecture (v1.3)rajdeep
 

Viewers also liked (6)

curl and new technologies
curl and new technologiescurl and new technologies
curl and new technologies
 
Internet all the things - curl everywhere!
Internet all the things - curl everywhere!Internet all the things - curl everywhere!
Internet all the things - curl everywhere!
 
HTTP/2 - for TCP/IP Geeks Stockholm
HTTP/2 - for TCP/IP Geeks StockholmHTTP/2 - for TCP/IP Geeks Stockholm
HTTP/2 - for TCP/IP Geeks Stockholm
 
Http2 right now
Http2 right nowHttp2 right now
Http2 right now
 
주로사용되는 Xss필터와 이를 공격하는 방법
주로사용되는 Xss필터와 이를 공격하는 방법주로사용되는 Xss필터와 이를 공격하는 방법
주로사용되는 Xss필터와 이를 공격하는 방법
 
Docker Architecture (v1.3)
Docker Architecture (v1.3)Docker Architecture (v1.3)
Docker Architecture (v1.3)
 

Similar to The many uses of the cURL command line tool

REST and JAX-RS
REST and JAX-RSREST and JAX-RS
REST and JAX-RSGuy Nir
 
Rpi python web
Rpi python webRpi python web
Rpi python websewoo lee
 
Basic testing with selenium
Basic testing with seleniumBasic testing with selenium
Basic testing with seleniumSøren Lund
 
REST Web Sebvice
REST Web SebviceREST Web Sebvice
REST Web Sebvicekhmerforge
 
Cache is king
Cache is kingCache is king
Cache is kingedrone
 
OWASP Top 10 - Checkmarx Presentation at Polytechnic Institute of Cávado and Ave
OWASP Top 10 - Checkmarx Presentation at Polytechnic Institute of Cávado and AveOWASP Top 10 - Checkmarx Presentation at Polytechnic Institute of Cávado and Ave
OWASP Top 10 - Checkmarx Presentation at Polytechnic Institute of Cávado and AveCheckmarx
 
Web Application Security 101 - 02 The Basics
Web Application Security 101 - 02 The BasicsWeb Application Security 101 - 02 The Basics
Web Application Security 101 - 02 The BasicsWebsecurify
 
Big Data & Cloud | Cloud Storage Simplified | Adrian Cole
Big Data & Cloud | Cloud Storage Simplified | Adrian ColeBig Data & Cloud | Cloud Storage Simplified | Adrian Cole
Big Data & Cloud | Cloud Storage Simplified | Adrian ColeJAX London
 
Interactive web. O rly?
Interactive web. O rly?Interactive web. O rly?
Interactive web. O rly?timbc
 
Making the Most of HTTP In Your Apps
Making the Most of HTTP In Your AppsMaking the Most of HTTP In Your Apps
Making the Most of HTTP In Your AppsBen Ramsey
 
Hidden Gems in HTTP
Hidden Gems in HTTPHidden Gems in HTTP
Hidden Gems in HTTPBen Ramsey
 
Bootstrapping multidc observability stack
Bootstrapping multidc observability stackBootstrapping multidc observability stack
Bootstrapping multidc observability stackBram Vogelaar
 
Devoxx Maroc 2015 HTTP 1, HTTP 2 and folks
Devoxx Maroc  2015 HTTP 1, HTTP 2 and folksDevoxx Maroc  2015 HTTP 1, HTTP 2 and folks
Devoxx Maroc 2015 HTTP 1, HTTP 2 and folksNicolas Martignole
 
HTTP fundamentals for developers
HTTP fundamentals for developersHTTP fundamentals for developers
HTTP fundamentals for developersMario Cardinal
 

Similar to The many uses of the cURL command line tool (20)

HTTP
HTTPHTTP
HTTP
 
REST and JAX-RS
REST and JAX-RSREST and JAX-RS
REST and JAX-RS
 
Rpi python web
Rpi python webRpi python web
Rpi python web
 
Http2 kotlin
Http2   kotlinHttp2   kotlin
Http2 kotlin
 
Basic testing with selenium
Basic testing with seleniumBasic testing with selenium
Basic testing with selenium
 
Server architecture
Server architectureServer architecture
Server architecture
 
Ethernet Shield
Ethernet ShieldEthernet Shield
Ethernet Shield
 
Web tech 101
Web tech 101Web tech 101
Web tech 101
 
REST Web Sebvice
REST Web SebviceREST Web Sebvice
REST Web Sebvice
 
Cache is king
Cache is kingCache is king
Cache is king
 
Cache is the king
Cache is the kingCache is the king
Cache is the king
 
OWASP Top 10 - Checkmarx Presentation at Polytechnic Institute of Cávado and Ave
OWASP Top 10 - Checkmarx Presentation at Polytechnic Institute of Cávado and AveOWASP Top 10 - Checkmarx Presentation at Polytechnic Institute of Cávado and Ave
OWASP Top 10 - Checkmarx Presentation at Polytechnic Institute of Cávado and Ave
 
Web Application Security 101 - 02 The Basics
Web Application Security 101 - 02 The BasicsWeb Application Security 101 - 02 The Basics
Web Application Security 101 - 02 The Basics
 
Big Data & Cloud | Cloud Storage Simplified | Adrian Cole
Big Data & Cloud | Cloud Storage Simplified | Adrian ColeBig Data & Cloud | Cloud Storage Simplified | Adrian Cole
Big Data & Cloud | Cloud Storage Simplified | Adrian Cole
 
Interactive web. O rly?
Interactive web. O rly?Interactive web. O rly?
Interactive web. O rly?
 
Making the Most of HTTP In Your Apps
Making the Most of HTTP In Your AppsMaking the Most of HTTP In Your Apps
Making the Most of HTTP In Your Apps
 
Hidden Gems in HTTP
Hidden Gems in HTTPHidden Gems in HTTP
Hidden Gems in HTTP
 
Bootstrapping multidc observability stack
Bootstrapping multidc observability stackBootstrapping multidc observability stack
Bootstrapping multidc observability stack
 
Devoxx Maroc 2015 HTTP 1, HTTP 2 and folks
Devoxx Maroc  2015 HTTP 1, HTTP 2 and folksDevoxx Maroc  2015 HTTP 1, HTTP 2 and folks
Devoxx Maroc 2015 HTTP 1, HTTP 2 and folks
 
HTTP fundamentals for developers
HTTP fundamentals for developersHTTP fundamentals for developers
HTTP fundamentals for developers
 

More from Kyosuke MOROHASHI

Ruby ecosystem applied to agile project
Ruby ecosystem applied to agile projectRuby ecosystem applied to agile project
Ruby ecosystem applied to agile projectKyosuke MOROHASHI
 
Test Context Arrangement Recipebook
Test Context Arrangement RecipebookTest Context Arrangement Recipebook
Test Context Arrangement RecipebookKyosuke MOROHASHI
 
Begin cucumber-in-real-world
Begin cucumber-in-real-worldBegin cucumber-in-real-world
Begin cucumber-in-real-worldKyosuke MOROHASHI
 
Rails testing environment, 2009 fall
Rails testing environment, 2009 fallRails testing environment, 2009 fall
Rails testing environment, 2009 fallKyosuke MOROHASHI
 
TDD frameworks let me dream "Project Specific Language"
TDD frameworks let me dream "Project Specific Language"TDD frameworks let me dream "Project Specific Language"
TDD frameworks let me dream "Project Specific Language"Kyosuke MOROHASHI
 
OSC2008 勉強会大集合 Rails勉強会@東京
OSC2008 勉強会大集合 Rails勉強会@東京OSC2008 勉強会大集合 Rails勉強会@東京
OSC2008 勉強会大集合 Rails勉強会@東京Kyosuke MOROHASHI
 
Capistrano in practice - WebCareer
Capistrano in practice - WebCareerCapistrano in practice - WebCareer
Capistrano in practice - WebCareerKyosuke MOROHASHI
 
named_scope more detail - WebCareer
named_scope more detail - WebCareernamed_scope more detail - WebCareer
named_scope more detail - WebCareerKyosuke MOROHASHI
 
そうだ勉強会に行こう
そうだ勉強会に行こうそうだ勉強会に行こう
そうだ勉強会に行こうKyosuke MOROHASHI
 

More from Kyosuke MOROHASHI (13)

Ruby ecosystem applied to agile project
Ruby ecosystem applied to agile projectRuby ecosystem applied to agile project
Ruby ecosystem applied to agile project
 
Test Context Arrangement Recipebook
Test Context Arrangement RecipebookTest Context Arrangement Recipebook
Test Context Arrangement Recipebook
 
Begin cucumber-in-real-world
Begin cucumber-in-real-worldBegin cucumber-in-real-world
Begin cucumber-in-real-world
 
Cucumber in Practice(en)
Cucumber in Practice(en)Cucumber in Practice(en)
Cucumber in Practice(en)
 
Rails testing environment, 2009 fall
Rails testing environment, 2009 fallRails testing environment, 2009 fall
Rails testing environment, 2009 fall
 
TDD frameworks let me dream "Project Specific Language"
TDD frameworks let me dream "Project Specific Language"TDD frameworks let me dream "Project Specific Language"
TDD frameworks let me dream "Project Specific Language"
 
Rails Tokyo 035 Cucumber
Rails Tokyo 035 CucumberRails Tokyo 035 Cucumber
Rails Tokyo 035 Cucumber
 
OSC2008 勉強会大集合 Rails勉強会@東京
OSC2008 勉強会大集合 Rails勉強会@東京OSC2008 勉強会大集合 Rails勉強会@東京
OSC2008 勉強会大集合 Rails勉強会@東京
 
Capistrano in practice - WebCareer
Capistrano in practice - WebCareerCapistrano in practice - WebCareer
Capistrano in practice - WebCareer
 
named_scope more detail - WebCareer
named_scope more detail - WebCareernamed_scope more detail - WebCareer
named_scope more detail - WebCareer
 
named_scope more detail
named_scope more detailnamed_scope more detail
named_scope more detail
 
Rails <form> Chronicle
Rails <form> ChronicleRails <form> Chronicle
Rails <form> Chronicle
 
そうだ勉強会に行こう
そうだ勉強会に行こうそうだ勉強会に行こう
そうだ勉強会に行こう
 

Recently uploaded

08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilV3cube
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 

Recently uploaded (20)

08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 

The many uses of the cURL command line tool

  • 1. cURL ( ) 2011-09-12( )
  • 2. curl - transfer a URL • curl is a tool to transfer data from or to a server, using one of the supported protocols (DICT, FILE, FTP, FTPS, GOPHER, HTTP, HTTPS, IMAP, IMAPS, LDAP, LDAPS, POP3, POP3S, RTMP, RTSP, SCP, SFTP, SMTP, SMTPS, TELNET and TFTP). 2011-09-12( )
  • 3. why cURL is useful? • curl -O http://example.com/ wallpapers/img[01-19].jpg 2011-09-12( )
  • 4. why cURL is useful for Web Developers 2011-09-12( )
  • 5. HTTP $ telnet www.google.co.jp 80 Trying 74.125.153.105... Connected to www.l.google.com. Escape character is '^]'. GET / HTTP/1.1 Host: www.google.co.jp < > 2011-09-12( )
  • 6. GET / HTTP/1.1 [method] [request-uri] HTTP/1.1 2011-09-12( )
  • 8. Host: www.google.co.jp Host: < > 2011-09-12( )
  • 9. HTTP $ telnet www.google.co.jp 80 Trying 74.125.153.105... Connected to www.l.google.com. Escape character is '^]'. GET / HTTP/1.1 Host: www.google.co.jp < > 2011-09-12( )
  • 10. curl $ curl -v http://www.google.co.jp * About to connect() to www.google.co.jp port 80 (#0) * Trying 74.125.153.106... connected* Connected to www.google.co.jp (74.125.153.106) port 80 (#0) > GET / HTTP/1.1 > User-Agent: curl/7.21.7 ... > Host: www.google.co.jp > Accept: */* > < HTTP/1.1 200 OK < Date: Thu, 08 Sep 2011 06:47:44 GMT < Expires: -1 < Cache-Control: private, max-age=0 2011-09-12( )
  • 11. curl --head curl --verbose|-v (curl --trace-ascii dump) 2011-09-12( )
  • 12. HTTP Header $ curl -v http://www.google.co.jp * (ry) > GET / HTTP/1.1 > User-Agent: curl/7.21.7 ... > Host: www.google.co.jp > Accept: */* > < HTTP/1.1 200 OK < Date: Thu, 08 Sep 2011 06:47:44 GMT < Expires: -1 < Cache-Control: private, max-age=0 2011-09-12( )
  • 13. HTTP Request Headers Accept Accept-Language Authorization Host Referer User-Agent 2011-09-12( )
  • 14. $ curl -v -H 'Accept-Language: ja' http://twitter.com | nokogrep -a content 'meta[name=description]' > GET / HTTP/1.1 > User-Agent: curl/7.21.7 > Host: twitter.com > Accept: */* > Accept-Language: ja > < HTTP/1.1 200 OK ... 2011-09-12( )
  • 15. $ curl -v -H 'Accept-Language: en' http://twitter.com | nokogrep -a content 'meta[name=description]' > GET / HTTP/1.1 > User-Agent: curl/7.21.7 > Host: twitter.com > Accept: */* > Accept-Language: en > < HTTP/1.1 200 OK ... Instantly connect to what's most important to you. Follow your friends, experts, favorite celebrities, and breaking news. 2011-09-12( )
  • 16. $ curl -v -H 'Accept: application/json' http://jobs.dev/jobs | ruby -rpp -rjson -e 'pp JSON.parse(STDIN.read)' > GET /jobs HTTP/1.1 > User-Agent: curl/7.21.7 > Host: jobs.dev > Accept: application/json 2011-09-12( )
  • 17. < HTTP/1.1 200 OK < Content-Type: application/json; charset=utf-8 < X-UA-Compatible: IE=Edge < ETag: "1490b2d47b09a5abb92bd7eb09c4c51e" < Cache-Control: max-age=0, private, must-revalidate < X-Runtime: 0.059816 < Connection: keep-alive < Transfer-Encoding: chunked [{"created_at"=>"2011-09-07T05:56:22Z", "deadline"=>"2011-09-07", "description"=>" !!!", "id"=>1, "public"=>true, "title"=>"10 ", "updated_at"=>"2011-09-07T09:59:33Z"}] 2011-09-12( )
  • 18. HTTP Response HTTP/1.1 200 OK Date: Mon, 12 Sep 2011 01:27:34 GMT Server: hi Status: 200 OK ETag: "ceedd0ac4f0339411aab820e225afcdf" Content-Type: text/html; charset=utf-8 Content-Length: 44188 Pragma: no-cache Expires: Tue, 31 Mar 1981 05:00:00 GMT Cache-Control: no-cache, no-store, must- revalidate, pre-check=0, post-check=0 X-XSS-Protection: 1; mode=block 2011-09-12( )
  • 19. HTTP Response HTTP/1.1 200 OK Date: Mon, 12 Sep 2011 01:27:34 GMT Server: hi Status: 200 OK ETag: "ceedd0ac4f0339411aab820e225afcdf" Content-Type: text/html; charset=utf-8 Content-Length: 44188 Pragma: no-cache Expires: Tue, 31 Mar 1981 05:00:00 GMT Cache-Control: no-cache, no-store, must- revalidate, pre-check=0, post-check=0 X-XSS-Protection: 1; mode=block 2011-09-12( )
  • 20. Status line 200 302 400 404 500 503 2011-09-12( )
  • 21. HTTP Status is app UI 200 404 ? 410(Gone) 2011-09-12( )
  • 22. HTTP Response Headers Location Server Content-Type Content-Length Expire, ETag, Cache-Control 2011-09-12( )
  • 24. POST via curl $ curl -v -d email=moro@example.jp -d password=hogehoge http://example.com/users POST /users HTTP/1.1 User-Agent: curl/7.21.7 Host: example.com Accept: */* Content-Length: 36 Content-Type: application/x-www-form-urlencoded 2011-09-12( )
  • 25. HTTP/1.1 201 Created Content-Type: application/json Date: Mon, 12 Sep 2011 01:43:41 GMT Server: journey/0.4.0 Content-Length: 71 Connection: keep-alive {"email":"moro@example.jp","_id":"4e6d63cd981 5710100000005","profiles":[]} 2011-09-12( )
  • 27. HTTP Authentication $ curl -v -u moro@example.jp:hogehoge http://example.com/account GET /account HTTP/1.1 Authorization: Basic bW9yb0BleGFtcGxlLmpwOmhvZ2Vob2dl User-Agent: curl/7.21.7 Host: example.com Accept: */* 2011-09-12( )
  • 28. HTTP Authentication HTTP/1.1 200 OK Content-Type: application/json Date: Mon, 12 Sep 2011 01:51:00 GMT Server: journey/0.4.0 Content-Length: 71 Connection: keep-alive {"email":"moro@example.jp","_id":"4e6d63cd9 815710100000005","profiles":[]} 2011-09-12( )
  • 29. cookie & cURL http://flic.kr/p/5ekGdX 2011-09-12( )
  • 30. cookie • HTTP {Cookie} Web http://www.studyinghttp.net/cookies 2011-09-12( )
  • 31. [res] Set-Cookie [req] Cookie • Netscape Set-Cookie Cookie 2 HTTP http://www.studyinghttp.net/cookies#HeadersForCookie 2011-09-12( )
  • 35. without cookie $ curl -q http://jobs.dev | nokogrep '#header p.greeting' Who are you? Sign in 2011-09-12( )
  • 36. Cookie & cURL $ curl -v -b '_jobs_session=BAh7CEkiD3Nl( )' http://jobs.dev | nokogrep '#header p.greeting' GET / HTTP/1.1 User-Agent: curl/7.21.7 Host: jobs.dev Accept: */* Cookie: _jobs_session=BAh7CEkiD3Nl( ) 2011-09-12( )
  • 37. Cookie & cURL HTTP/1.1 200 OK Content-Type: text/html; charset=utf-8 X-UA-Compatible: IE=Edge ETag: "8c0c63144925e4cc29b655906c221a3f" Set-Cookie:_jobs_session=BAh7CEkiD3Nl( ) X-Runtime: 0.156343 Connection: keep-alive Transfer-Encoding: chunked Hi moro@example.jp Sign out 2011-09-12( )
  • 39. $ curl -v -d 'user[email]=moro@example.jp' -d 'user[password]=hogehoge' http://jobs.dev/users/sign_in POST /users/sign_in HTTP/1.1 User-Agent: curl/7.21.7 Host: jobs.dev Accept: */* Content-Length: 51 Content-Type: application/x-www-form-urlencoded 2011-09-12( )
  • 40. HTTP/1.1 302 Moved Temporarily Location: http://jobs.dev/ Content-Type: text/html; charset=utf-8 X-UA-Compatible: IE=Edge Cache-Control: no-cache Set-Cookie: _jobs_session=BAh7CE( ) X-Runtime: 0.217055 Connection: keep-alive Transfer-Encoding: chunked <html><body>You are being <a href="http://jobs.dev/">redirected</ a>.</body></html> 2011-09-12( )
  • 41. $ curl -v -b '_jobs_session=BAh7CE( )' http://jobs.dev/ | nokogrep '#header p.greeting' GET / HTTP/1.1 User-Agent: curl/7.21.7 Host: jobs.dev Accept: */* Cookie: _jobs_session=BAh7CE( ) 2011-09-12( )
  • 42. HTTP/1.1 200 OK Content-Type: text/html; charset=utf-8 X-UA-Compatible: IE=Edge ETag: "98d16875bdceb8c5451e7706e6071ece" Cache-Control: max-age=0, private, must-revalidate Set-Cookie: _jobs_session=BAh7CUki( ) X-Runtime: 0.193951 Connection: keep-alive Transfer-Encoding: chunked Hi moro@example.jp Sign out 2011-09-12( )
  • 44. see also • http://www.studyinghttp.net/ • http://www.studyinghttp.net/ rfc_ja/rfc2616 • http://amazon.jp/dp/ 4774142042/morodiary05-22/ ref=nosim/ 2011-09-12( )