All	
  That	
  	
  
Hyper	
  Text	
  Transfer	
  Protocol	
  
강상진	
  
Email:	
  sangjinn@gmail.com	
  
Twi;er:	
  @sangjinn	
  
2015년 7월	
  
강상진
 (Brandon
 Kang)
 
 
전)
 삼성SDS
 솔루션
 개발센터
 선임
 개발자
 
전)
 한국마이크로소프트
 소프트웨어
 연구소
 책임
 연구원
 
현)
 아카마이
 한국
 법인
 시니어
 기술
 프로젝트
 매니저
 리드
 
 
IT
 도서
 집필/번역
 
IT
 트렌드,
 웹
 프로그래밍,
 모바일
 앱
 개발,
 게임
 개발
 등
 
 
IT
 강연/강의/기고
 
KOBA,

HTTP 프로토콜의 이해와 활용

  • 1.
    All  That     Hyper  Text  Transfer  Protocol   강상진   Email:  sangjinn@gmail.com   Twi;er:  @sangjinn   2015년 7월  
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
  • 26.
  • 27.
  • 28.
  • 29.
  • 30.
  • 31.
  • 32.
  • 33.
  • 34.
  • 35.
  • 36.
  • 37.
  • 38.
  • 39.
  • 40.
  • 41.
  • 42.
  • 43.
  • 44.
  • 45.
  • 46.
  • 47.
  • 48.
  • 49.
  • 50.
  • 51.
  • 52.
  • 53.
  • 54.
  • 55.
  • 56.
  • 57.
  • 58.
  • 59.
  • 60.
  • 61.
  • 62.
  • 63.
  • 64.
    Internet   •  1969  미 국방성 알파넷(ARPANET)  등장 •  1972  이메일 탄생 •  1974  인터넷(Internet)  용어 처음 사용 •  1975  TCP/IP  개발,  시운전 개시 •  1979  USENET  구축(net*  뉴스그룹 생성)   •  1982  TCP/IP  도입 (  인터넷 개념 정립 )   •  1984  DNS  (Domain  Name  System  )  제시 •  1986  NSFNET  구축 •  1991  팀 버너스 리에 의해 WWW(WorldWideWeb)  개발 •  1993  InterNIC,  Mosaic  등장으로 WWW  사용률 급증 •  1994  넷스케이프 네비게이터 1.0  발표 ,  W3C  구성 •  1995  NSFNET  해체되고 ISP  등이 운용.  본격 상업화,  대중화,  정보 고속화 •  1996  MS  Internet  Explorer  발표 •  1998  세계 인터넷 이용자수 1억 명 돌파  
  • 65.
    HTTP   •  The  most  popular  TCP  protocol   •  Protocol  for  web   •  Generally,  Between  web  browser  and  web  server   •  Request  -­‐  Response  Structure   •  HTTP  0.9,  1.0,  1.1    2.0  (Feb.  2015  Now)  
  • 66.
    HTTP  History   • HTTP  0.9  -­‐  HTTP의 탄생 팀 버너스리가 최초에 웹을 발명했을 때 사용하던 프로토콜 현재의 HTTP와 다르게 헤더가 없으며,  GET  메소드만 있음.     •  HTTP  1.0  -­‐  HTTP  최초의 표준화 IETF  에서 표준화하여 1993년에 Drac  공개후,  1996년에 최종 버전(RFC  1945)   헤더의 도입,  GET  이외의 메서드 추가   •  HTTP  1.1  -­‐  HTTP의 완성 1997년 RFC  2068  에서 개정하여 1999년 RFC  2616  발행.  현재의 1.1  스펙 채널전송,  Accept  헤더에 의한 content  negodadon,  cache-­‐control,     Keep-­‐Alive  등 추가   •  SPDY  -­‐  좀더 빠른 웹을 위한 실험적인 프로토콜 구글이 제안하는 HTTP  프로토콜의 개선안.     SSL/헤더 압축/다중 스트림/요청 우선 순위 등     HTTP/2
  • 67.
  • 68.
  • 69.
  • 70.
  • 71.
  • 72.
    URI  (Uniform  Resource  Idendfiers)  
  • 73.
    -­‐  Quiz  -­‐         URL과 URI의 차이점은?  
  • 74.
    Uniform  Resource  Idenfier  (URI)     is  a  string  of  characters  used  to  idendfy  a  name  or  a  web  resource     h;p://www.apple.com/iphone/features/   h;p://www.apple.com/ipad/specs/   h;p://www.apple.com/macbook-­‐pro/performance/   h;p://www.apple.com/support/iphone/syncing/   Uniform  Resource  Locator  (URL)  (also  known  as  web  address,  pardcularly  when   used  with  HTTP)  is  a  specific  character  string  that  consdtutes  a  reference  to  a   resource.   Uniform  Resource  Name  (URN)   is  the  historical  name  for  a  Uniform  Resource  Idendfier  (URI)  that  uses  the  urn:   scheme.   한글 깔끔정리 h;p://blog.lael.be/post/61    
  • 75.
    HTTP  Operadon   Before  systems  can  exchange  HTTP   messages,  they  must  establish  a  TCP   connecdon.  Steps  1,  2,  and  3  in  this   example  show  the  connecdon   establishment.  Once  the  TCP   connecdon  is  available,  the  client   sends  the  server  an  HTTP  request.  The   final  two  steps,  6  and  7,  show  the   closing  of  the  TCP  connecdon.  
  • 76.
    HTTP  Operadon   Before  systems  can  exchange  HTTP   messages,  they  must  establish  a  TCP   connecdon.  Steps  1,  2,  and  3  in  this   example  show  the  connecdon   establishment.  Once  the  TCP   connecdon  is  available,  the  client   sends  the  server  an  HTTP  request.  The   final  two  steps,  6  and  7,  show  the   closing  of  the  TCP  connecdon.  
  • 77.
    Persistent  Connecdon  (HTTP1.X)     With  persistent  connecdons,  a  client   can  issue  many  HTTP  requests  over  a   single  TCP  connecdon.  The  first   request  is  in  step  4,  which  the  server   answers  in  step  5.  In  step  6  the  client   condnues  by  sending  the  server   another  request  on  the  same  TCP   connecdon.  The  server  responds  to   this  request  in  step  7  and  then  closes   the  TCP  connecdon.   참고:  h;ps://en.wikipedia.org/wiki/HTTP_persistent_connecdon    
  • 78.
    Pipelining  (HTTP1.1)   Pipelining  lets  an  HTTP  client  issue   new  requests  without  waidng  for   responses  from  its  previous   messages.  In  the  figure,  the  client   sends  its  first  request  in  step  4.  It   immediately  follows  that  with  a   second  request  in  step  5.  The  client   does  not  wait  for  the  server’s   response,  which  arrives  in  step  6.   참고:  h;ps://en.wikipedia.org/wiki/HTTP_pipelining    
  • 79.
    HTTP  Method   GET   POST   …   CONNECT   PUT   DELETE   OPTION   TRACE   WebDAV   …  
  • 80.
    -­‐  Quiz  -­‐         왜 POST를 사용하는가?   GET과는 무엇이 다른가?  
  • 81.
    GET  /  POST   A  server  responds  to  a  POST  request   by  returning  new  informadon  such  as   search  results.  This  informadon  is   carried  as  data  in  the  response.   A  server  responds  to  a  GET  request  by   returning  the  requested  resource,   ocen  a  new  Web  page.  The  new  page   is  the  data  in  the  response.   POST  is  using  when  client  wants  to  send  data  to  server.  ex)  Web  Forms  
  • 82.
    OPTION  /  HEAD   The  HEAD  request  mimics  a  GET   operadon,  except  that  the  server  does   not  actually  return  the  requested   object,  only  HTTP  headers.   Clients  can  use  an  OPTIONS  request  to   ask  about  a  pardcular  object  or  about   the  server  itself.  The  server  returns  the   opdons  data  in  its  response.   OPTION  is  ocen  used  by  hackers  to  find  out  which  method  web  server  support.  
  • 83.
    PUT  /  DELETE   The  DELETE  operadon  lets  a  client   remove  an  object  from  a  server.  The   URI  idendfies  the  object  to  delete.   Clients  can  use  the  PUT  request  to   send  a  new  object  to  a  server.  The  URI   that’s  part  of  the  request  tells  the   server  where  to  put  the  object.   PUT    DELETE  should  be  granted  ONLY  permi;ed  admins  
  • 84.
    TRACE     The  TRACE  request  lets  clients   discover  the  path  their  messages   follow  through  a  network  of   intermediate  servers.   The  TRACE  message  gives  clients  a  way  to   check  the  network  path  to  a  server.  When  a   server  receives  a  TRACE,  it  responds  simply  by   copying  the  TRACE  message  itself  into  the  data   for  the  response.   TRACE  are  more  useful  when  muldple  servers  are  involved  in  responding  a  request  
  • 85.
    Virtual  Hosdng   Virtual  hosdng  lets  many  Web  addresses  share  the  same  Web  server.   This  configuradon  is  typical  in  ISPs  that  provide  Web  hosdng  for  small   businesses  and  individuals.  
  • 86.
    -­‐  Quiz  -­‐       요청 헤더(Req.  header) 중,   HOST 헤더가 필요한 이유는?  
  • 87.
    Before  Virtual  Hosdng    HTTP  1.1   instead  of  the   straighrorward  uri  “h;p://www.company1.com/news.html,”   the  company1.com  Web  site  might  use  the  more  complicated  like  “h;p:// www.company1.com/company1.com/news.html.”  
  • 88.
    Proxy  Server   A  proxy  server  posidons  itself  in  between  clients  and  servers.     It  forwards  requests  on  behalf  of  clients  and  relays  responses  from  the  servers.  
  • 89.
    Gateway   A  gateway  accepts  HTTP  requests  and  translates  them  to  a  different   format  such  as  SQL.  The  gateway  also  ensures  that  any  reply  is  a   proper  HTTP  response.  
  • 90.
    HTTP  Request   An  HTTP  request  begins  with  a   Request-­‐Line  and  may  include   headers  and  a  message  body.  The   headers  can  describe  general   communicadons,  the  specific  request,   or  the  included  message  body.  
  • 91.
    HTTP  Response   An  HTTP  response  begins  with  a   Status-­‐Line  and  may  include  headers   and  a  message  body.  The  headers  can   describe  the  general  communicadons,   the  specific  response,  or  the  included   message  body.  
  • 92.
  • 93.
  • 94.
    Accept  Series   The  Accept  header,  which  is  a  request  header,  lets  a  client  explicitly  indicate  what   types  of  content  it  can  accept  in  the  message  body  of  the  server’s  response,  as  well  as   its  reladve  preference  for  each  content  type.   The  Accept-­‐Encoding  header  gives  clients  another  way  to  express  their  preferences  for   the  message  body  of  the  server’s  response   Clients  can  include  an  Accept-­‐Charset  header  in  their  requests   to  tell  the  server  which  character  encodings  they  prefer   for  the  message  body  returned  in  the  response.  
  • 95.
    -­‐  Quiz  -­‐         브라우저에 캐시된   콘텐트는 언제까지 사용되는가?  
  • 96.
  • 97.
  • 98.
    Cookie   Servers  can  return  state  management  cookies  in  their  responses.     Clients,  if  they  wish,  include  those  cookies  in  subsequent  requests  to  the  same   server.  
  • 99.
    -­‐  Quiz  -­‐       크기가 매우 큰 파일의   일부만을 다운받고 싶다면?   Ex)  P2P  applicadon  
  • 100.
  • 101.
  • 102.
    Range  Request   Pardal  GET   HTTP  Request가 늘어나는 방식   YouTube  :  h;p://www.youtube.com/watch?v=2ips2mM7Zqw     한글 블로그 참고:  h;p://npcode.com/blog/archives/762   영문 블로그 참고:  h;p://stackoverflow.com/quesdons/8293687/sample-­‐h;p-­‐range-­‐request-­‐session      
  • 103.
    If  Series   The  If-­‐Range  header  lets  a  client  ask  for  either   part  of  an  object  or,  if  the  part  is  no  longer   valid,  the  endre  object,  all  in  a  single  request.   A  proxy  server  can  use  the  If-­‐Modified   header  to  ask  for  an  object  only  if  it   has  changed.  In  this  example  the   object  has  not  changed,  so  the  server   returns  a  304  status.  
  • 104.
    -­‐  Quiz  -­‐         301  /  302  Response  의   차이점은?   참고:  h;p://www.seo-­‐korea.com/301-­‐vs-­‐302-­‐redirect/    
  • 105.
    HTTP  Response  Code   h;p://www.w3.org/Protocols/rfc2616/rfc2616-­‐sec10.html    
  • 106.
    Demo     1.  Spoofing  Device     2.  Spoofing  Client  IP     3.  CURL  operadons   h;p://curl.haxx.se       4.  Charles  Proxy  tools  
  • 107.
    LAB  1)     Mock  Server 서비스를 활용하여   Request  Header  확인하기     h;p://requestb.in    
  • 108.
    LAB  2)     Mock  Server 서비스를 활용하여   Response  Header  생성하기     h;p://www.mocky.io    
  • 109.
    Demo     1)  IP  DB  /  Device  DB  examples   h;p://edc.edgesuite.net       2)  HTTP/2  Demo   h;ps://h;p2.akamai.com      
  • 110.