Internet! & HTTP!
      잃어버린 패킷을 찾아서…


                 이동욱
               2009.12.05

          dugan.lee@gmail.com
        http://nephilim.tistory.com
1
HTML(5?)
                   CSS
             Javascript/Ajax

    HTTP    Javascript Library
                  Comet
                Flash/Flex
              RoR, Django
            PHP, Servlet/JSP,
                  ASP…

     1990        2009




2                        그림 출처 - http://en.wikipedia.org
1




            1-1                       1-2




    1-1-1         1-1-2       1-2-1         1-2-2




3
HTTP



                         …




                               javascript   기타 기술들…
    WWW   Server-Side                         (아악!)
                                  Ajax
            Scripts
                                Comet…




4
HTTP Request




                   1
                   GET / HTTP/1.1
                   Host: 127.0.0.1:8080
                   User-Agent: Mozilla/5.0 …
                   Accept: text/html,application/xml;…
                   Accept-Language: ko-kr,ko;q=0.8,en-us
                   Accept-Encoding: gzip,deflate
                   Accept-Charset: EUC-KR,utf-8;q=0.7,*;q=0.7
                   Keep-Alive: 300
                   Connection: keep-alive




5
HTTP Response




                    2
                        HTTP/1.1 200 OK
                        Server: Apache-Coyote/1.1
                        Accept-Ranges: bytes
                        ETag: W/"331-1259569714921"
                        Last-Modified: Mon, 30 Nov 2009 08:28:34 GMT
                        Content-Type: text/html
                        Content-Length: 331
                        Date: Mon, 30 Nov 2009 08:32:30 GMT

                        <html>
                        <head>
                        <title>IBM PetchaKucha</title>
                        </head>
                        <body>
                        Hello Web World!
                        <hr/>
                        <font color="red" size="10"> 안녕하세요</font>
                        </body>
                        </html>
6
많은 Resource들




          <html>
          <body>
              <img   src="images/h.png"   />
              <img   src="images/t.png"   />
              <img   src="images/t.png"   />
              <img   src="images/p.png"   />
          </body>
          </html>




                        (ex) jQuery UI         http://jqueryui.com/themeroller/images/?new=2e83ff&w=256&h=240&f=pn
7                                              g&fltr[]=rcd|256&fltr[]=mask|icons/icons.png
1
    Resource 일부       GET /wicket/1.4.3/apache-wicket-1.4.3.zip HTTP/1.1
                      Host: apache.mirror.cdnetworks.com
                      User-Agent: Mozilla/5.0
                      Accept: text/html,application/xhtml+xml,application/xml
                      Accept-Language: ko-kr,ko;q=0.8,en-us;q=0.5,en;q=0.3
                      Accept-Encoding: gzip,deflate
                      Accept-Charset: EUC-KR,utf-8
                      Keep-Alive: 300
                      Connection: keep-alive
                      Referer: http://apache.mirror.cdnetworks.com/wicket/1.4.3/
                      Range: bytes=21341986-
                      If-Match: "d20802f-1d98c87-476447ce3cc00"
                      If-Unmodified-Since: Mon, 19 Oct 2009 07:13:52 GMT


                  2
                      HTTP/1.1 206 Partial Content
                      Date: Tue, 01 Dec 2009 15:38:24 GMT
                      Server: Apache
                      Last-Modified: Mon, 19 Oct 2009 07:13:52 GMT
                      ETag: "d20802f-1d98c87-476447ce3cc00"
                      Accept-Ranges: bytes
                      Content-Length: 9692517
                      Content-Range: bytes 21341986-31034502/31034503
                      Keep-Alive: timeout=15, max=1000
                      Connection: Keep-Alive
                      Content-Type: application/zip

                      D/0k…(파일 내용)…
8
Form



    <form action="/" method="post">
         <input name="key1" value="value1-1"/>
         <input name="key1" value="value1-2"/>
         <input name="key2" value="value2"/>
    <input type="submit"/>
    </form>




    1
    POST http://192.168.0.100:8080/ HTTP/1.1
    Host: 192.168.0.100:8080
    …(중략)…
    Content-Type: application/x-www-form-urlencoded
    Content-Length: 39

    key1=value1-1&key1=value1-2&key2=value2




9
Form (계속)


       <form action="/" method="post">
            <input type="checkbox" name="checked" value="1"/>
            <input name="userdata" value="value1"/>
            <input type="checkbox" name="checked" value="2"/>
            <input name="userdata" value="value2"/>
            <input type="checkbox" name="checked" value="3"/>
            <input name="userdata" value="value3"/>
            <input type="submit"/>
       </form>



       1
       POST http://192.168.0.100:8080/ HTTP/1.1
       Host: 192.168.0.100:8080
       …(중략)…
       Content-Type: application/x-www-form-urlencoded          userdata의 개수 = 3개
       Content-Length: 51                                       checked의 개수 = 2개!

       check=1&userdata=value1&userdata=value2&check=3&userdata=value3



10
Redirection
                   1
                   GET http://yahoo.co.kr/ HTTP/1.1
                   Host: yahoo.co.kr
                   …

                   2
                   HTTP/1.1 301 Moved Permanently
                   Location: http://kr.yahoo.com
                   Vary: Accept-Encoding
                   Content-Type: text/html; charset=utf-8
                   Age: 533
                   Content-Length: 81

                   1
                   GET http://kr.yahoo.com/ HTTP/1.1
                   Host: kr.yahoo.com
                   …

                   2
                   HTTP/1.1 200 OK
                   Content-Type: text/html
                   …



11
Server-side (Java)




      public class RedirectServlet extends HttpServlet {

          @Override
          protected void service(HttpServletRequest request, HttpServletResponse response)
          throws ServletException, IOException {

                response.setStatus(302);
                response.setHeader("Location", "http://www.google.com");
          }
      }



                         response.sendRedirect("http://www.google.com");




12
조건부 GET (캐싱)
               1
               GET http://www.google.co.kr/… HTTP/1.1
               Host: www.google.co.kr
               …(중략)…
               If-Modified-Since: Tue, 10 Nov 2009 23:51:53 GMT
               Cache-Control: max-age=0


               2
               HTTP/1.1 304 Not Modified
               Date: Mon, 30 Nov 2009 16:25:58 GMT
               …




                   이후 브라우저가 Caching한 해당 리소스 표시




13
벌써 마무리…




        칼텍의 동료 교수 핚 사람이 파인만에게 질문을 던졌다.
         “스핀이 1/2인 입자들이 페르미­디랙의 통계를 따르는 이유가 뭘까?”
         파인만은 이렇게 말했다.


         “그 내용으로 1학년생들을 위핚 강의를 준비해 보겠네.”
        그러나 몇 주가 지난 후에 파인만은 솔직하게 털어 놓았다.


         “자네도 짐작했겠지만, 아직 강의 노트를 만들지 못했어. 학부 1학년생들
        도 알아듣게 설명핛 방법이 없더라구. 그러니까 내 말은, 우리가 아직 그것
        을 제대로 이해하지 못하고 있다는 뜻이야. 내 말 알아듣겠나?”


                                    - 파인만의 물리학 강의 중-


14
참고 자료


     URL
       http://www.w3.org/Protocols
       http://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol
       http://www.w3.org/2001/tag/webarch
       http://www.ietf.org/rfc/rfc3986 - URI
       http://code.google.com/intl/ko/apis/gdata/docs/2.0/reference.html#ResourceVersioning

     서적
       Chuck Musciano and Bill Kennedy, HTTP: The Definitive Guide, 2nd Edition, Oreilly, 1998
       Leonard Richardson and Sam Ruby, RESTful 웹 서비스 : 웹 서비스의 짂화, 정보문화사, 2008
       리차드 파인만, 파인만의 물리학 강의, 승산, 2004

     도구
       cURL               (http://curl.haxx.se )
       wireshark          (http:// www.wireshark.org)
       paros              (http:// www.parosproxy.org )
       firebug            (https://addons.mozilla.org/ko/firefox/addon/1843)
       google chrome      (http://chrome.google.com)


15

IBM dwLive, "Internet & HTTP - 잃어버린 패킷을 찾아서..."

  • 1.
    Internet! & HTTP! 잃어버린 패킷을 찾아서… 이동욱 2009.12.05 dugan.lee@gmail.com http://nephilim.tistory.com 1
  • 2.
    HTML(5?) CSS Javascript/Ajax HTTP Javascript Library Comet Flash/Flex RoR, Django PHP, Servlet/JSP, ASP… 1990 2009 2 그림 출처 - http://en.wikipedia.org
  • 3.
    1 1-1 1-2 1-1-1 1-1-2 1-2-1 1-2-2 3
  • 4.
    HTTP … javascript 기타 기술들… WWW Server-Side (아악!) Ajax Scripts Comet… 4
  • 5.
    HTTP Request 1 GET / HTTP/1.1 Host: 127.0.0.1:8080 User-Agent: Mozilla/5.0 … Accept: text/html,application/xml;… Accept-Language: ko-kr,ko;q=0.8,en-us Accept-Encoding: gzip,deflate Accept-Charset: EUC-KR,utf-8;q=0.7,*;q=0.7 Keep-Alive: 300 Connection: keep-alive 5
  • 6.
    HTTP Response 2 HTTP/1.1 200 OK Server: Apache-Coyote/1.1 Accept-Ranges: bytes ETag: W/"331-1259569714921" Last-Modified: Mon, 30 Nov 2009 08:28:34 GMT Content-Type: text/html Content-Length: 331 Date: Mon, 30 Nov 2009 08:32:30 GMT <html> <head> <title>IBM PetchaKucha</title> </head> <body> Hello Web World! <hr/> <font color="red" size="10"> 안녕하세요</font> </body> </html> 6
  • 7.
    많은 Resource들 <html> <body> <img src="images/h.png" /> <img src="images/t.png" /> <img src="images/t.png" /> <img src="images/p.png" /> </body> </html> (ex) jQuery UI http://jqueryui.com/themeroller/images/?new=2e83ff&w=256&h=240&f=pn 7 g&fltr[]=rcd|256&fltr[]=mask|icons/icons.png
  • 8.
    1 Resource 일부 GET /wicket/1.4.3/apache-wicket-1.4.3.zip HTTP/1.1 Host: apache.mirror.cdnetworks.com User-Agent: Mozilla/5.0 Accept: text/html,application/xhtml+xml,application/xml Accept-Language: ko-kr,ko;q=0.8,en-us;q=0.5,en;q=0.3 Accept-Encoding: gzip,deflate Accept-Charset: EUC-KR,utf-8 Keep-Alive: 300 Connection: keep-alive Referer: http://apache.mirror.cdnetworks.com/wicket/1.4.3/ Range: bytes=21341986- If-Match: "d20802f-1d98c87-476447ce3cc00" If-Unmodified-Since: Mon, 19 Oct 2009 07:13:52 GMT 2 HTTP/1.1 206 Partial Content Date: Tue, 01 Dec 2009 15:38:24 GMT Server: Apache Last-Modified: Mon, 19 Oct 2009 07:13:52 GMT ETag: "d20802f-1d98c87-476447ce3cc00" Accept-Ranges: bytes Content-Length: 9692517 Content-Range: bytes 21341986-31034502/31034503 Keep-Alive: timeout=15, max=1000 Connection: Keep-Alive Content-Type: application/zip D/0k…(파일 내용)… 8
  • 9.
    Form <form action="/" method="post"> <input name="key1" value="value1-1"/> <input name="key1" value="value1-2"/> <input name="key2" value="value2"/> <input type="submit"/> </form> 1 POST http://192.168.0.100:8080/ HTTP/1.1 Host: 192.168.0.100:8080 …(중략)… Content-Type: application/x-www-form-urlencoded Content-Length: 39 key1=value1-1&key1=value1-2&key2=value2 9
  • 10.
    Form (계속) <form action="/" method="post"> <input type="checkbox" name="checked" value="1"/> <input name="userdata" value="value1"/> <input type="checkbox" name="checked" value="2"/> <input name="userdata" value="value2"/> <input type="checkbox" name="checked" value="3"/> <input name="userdata" value="value3"/> <input type="submit"/> </form> 1 POST http://192.168.0.100:8080/ HTTP/1.1 Host: 192.168.0.100:8080 …(중략)… Content-Type: application/x-www-form-urlencoded userdata의 개수 = 3개 Content-Length: 51 checked의 개수 = 2개! check=1&userdata=value1&userdata=value2&check=3&userdata=value3 10
  • 11.
    Redirection 1 GET http://yahoo.co.kr/ HTTP/1.1 Host: yahoo.co.kr … 2 HTTP/1.1 301 Moved Permanently Location: http://kr.yahoo.com Vary: Accept-Encoding Content-Type: text/html; charset=utf-8 Age: 533 Content-Length: 81 1 GET http://kr.yahoo.com/ HTTP/1.1 Host: kr.yahoo.com … 2 HTTP/1.1 200 OK Content-Type: text/html … 11
  • 12.
    Server-side (Java) public class RedirectServlet extends HttpServlet { @Override protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setStatus(302); response.setHeader("Location", "http://www.google.com"); } } response.sendRedirect("http://www.google.com"); 12
  • 13.
    조건부 GET (캐싱) 1 GET http://www.google.co.kr/… HTTP/1.1 Host: www.google.co.kr …(중략)… If-Modified-Since: Tue, 10 Nov 2009 23:51:53 GMT Cache-Control: max-age=0 2 HTTP/1.1 304 Not Modified Date: Mon, 30 Nov 2009 16:25:58 GMT … 이후 브라우저가 Caching한 해당 리소스 표시 13
  • 14.
    벌써 마무리… 칼텍의 동료 교수 핚 사람이 파인만에게 질문을 던졌다. “스핀이 1/2인 입자들이 페르미­디랙의 통계를 따르는 이유가 뭘까?” 파인만은 이렇게 말했다. “그 내용으로 1학년생들을 위핚 강의를 준비해 보겠네.” 그러나 몇 주가 지난 후에 파인만은 솔직하게 털어 놓았다. “자네도 짐작했겠지만, 아직 강의 노트를 만들지 못했어. 학부 1학년생들 도 알아듣게 설명핛 방법이 없더라구. 그러니까 내 말은, 우리가 아직 그것 을 제대로 이해하지 못하고 있다는 뜻이야. 내 말 알아듣겠나?” - 파인만의 물리학 강의 중- 14
  • 15.
    참고 자료 URL http://www.w3.org/Protocols http://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol http://www.w3.org/2001/tag/webarch http://www.ietf.org/rfc/rfc3986 - URI http://code.google.com/intl/ko/apis/gdata/docs/2.0/reference.html#ResourceVersioning 서적 Chuck Musciano and Bill Kennedy, HTTP: The Definitive Guide, 2nd Edition, Oreilly, 1998 Leonard Richardson and Sam Ruby, RESTful 웹 서비스 : 웹 서비스의 짂화, 정보문화사, 2008 리차드 파인만, 파인만의 물리학 강의, 승산, 2004 도구 cURL (http://curl.haxx.se ) wireshark (http:// www.wireshark.org) paros (http:// www.parosproxy.org ) firebug (https://addons.mozilla.org/ko/firefox/addon/1843) google chrome (http://chrome.google.com) 15