SlideShare una empresa de Scribd logo
1 de 44
Descargar para leer sin conexión
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(   )

Más contenido relacionado

La actualidad más candente

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
 

La actualidad más candente (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
 

Destacado

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
 

Destacado (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 a Introduction HTTP via cURL

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 a Introduction HTTP via cURL (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
 

Más de 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
 

Más de 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
 
そうだ勉強会に行こう
そうだ勉強会に行こうそうだ勉強会に行こう
そうだ勉強会に行こう
 

Último

Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Bhuvaneswari Subramani
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesrafiqahmad00786416
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Victor Rentea
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxRemote DBA Services
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vázquez
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Orbitshub
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfOrbitshub
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusZilliz
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...apidays
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Jeffrey Haguewood
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistandanishmna97
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...apidays
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businesspanagenda
 

Último (20)

Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 

Introduction HTTP via cURL

  • 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( )