1 / 35

HTTP: prezentare generala

HTTP: prezentare generala. HTTP: prezentare generala. Web resources (1). URI, URN, ULR URI (Uniform Resource Identifier) URN (- // - Name) special URI semantic ID-role URL (- // - Locator) special URI semantic address-role HTML, XHTML Contents (HTML) Styles (CSS)

noleta
Download Presentation

HTTP: prezentare generala

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. HTTP: prezentare generala HTTP: prezentare generala

  2. Web resources (1) • URI, URN, ULR • URI (Uniform Resource Identifier) • URN (- // - Name) special URI semantic ID-role • URL (- // - Locator) special URI semantic address-role • HTML, XHTML • Contents (HTML) • Styles (CSS) • Dynamics (JavaScript) • XML • Definitions • DTD • Xml Schema • Parsing (SAX, DOM) • Translate (XSL, XSLT) • JSON (JavaScript Object Notation) • Definitions • Processing

  3. Web resources (2)

  4. URI, URN, URL Each web server resource has a name, so clients can point out what resources they are interested in. This resource name is called a uniform resource identifier, or URI The uniform resource locator (URL) is the most common form of resource identifier. URLs describe the specific location of a resource on a particular server. URLs specify protocol, server, and local resource: The second flavor of URI is the uniform resource name, or URN. A URN serves as a unique name for a particular piece of content, independent of where the resource currently resides.URNs are still experimental and not yet widely adopted.

  5. URI, URN, URL (2) <protocol>:[<user>@]<host>[:<port>][<path>][?<request>][#<fragment>] http://www.ubbcluj.ro http://www.ubbcluj.ro/cluj.html http://www.scs.ubbcluj.ro:8080/calcul/index.jsp?nr1=50&sir1=Ceva&nr2=40 http://www.scs.ubbcluj.ro:8080/calcul/medie?nr1=50&sir1=Ceva&nr2=40 http://www.cs.ubbcluj.ro/~florin/SO/index.html#ultimul http://en.wikipedia.org/wiki/URI#Examples_of_URI_references file:/d:/agenda/departament/fisier.h file://home/cs/florin/Socket.pdf ftp://ftp.netscape.com/pub/Linux/shell mailto:pop@scs.ubbcluj.ro?subject=Test&body=Salut%oAtinere%20internaut Ports: 20 – FTPdate, 21 – FTPcontrol, 25 – SMTP, 37 – TIME, 80 – HTTP, 443 – HTTPS, 1099 – RMI Template: http://www.serv.com/user/{userid} http://www.serv.com/users/absd0157

  6. HTML, XHTML, Browsers Mozilla Firefox, Internet Explorer, Opera, Safari, Google Chrome, KDE etc.

  7. (X)HTML source (1) <?xml version="1.0"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Primul document XHTML</title> <link rel="stylesheet" rev="stylesheet" href="forma.css" /> <script src="rotire.js" type="text/javascript" language="javascript"></script> </head> <body> <h1>Primul exemplu XHTML</h1> <table> <tr> <td><img src="ubb.jpg"/></td> <td><img src="gb.jpg" id="poze"/></td> </tr> <tr> <td>Universitatea Babes-Bolyai</td> <td>Imagini panoramice din Cluj</td> </tr> </table>

  8. (X)HTML (2) Acesta este un document minimal XHTML. El arata structura de baza si conceptul de ancora. <p> Pentru informatii<br/> suplimentare despre XHTML se poate consulta: <a href="http://www.w3.org/TR/xhtml11/"> prezentare XHTML</a> </p> Daca doriti sa trimiteti un E-mail persoanei care a scris acest fisier, va rog sa o faceti. <address> Reperele persoanei sunt: <a href = "http://cs.ubbcluj.ro/~florin">pagina personala</a> si <a href = "mailto:florin@cs.ubbcluj.ro">email</a>. <br/> </address> <b>Remarcati diferentele intre modul de scriere in XHTML si ceea ce apare pe ecran. </b> </body> </html>

  9. CSS source body { background-color:yellow ; color: black; font-size: 20px; font-family: "Lucida Grande", Verdana, Arial, Helvetica, sans-serif; } h1 { font-size: 28px; text-align: center; } table { border-collapse: collapse; } td { padding: 10px; border: 2px #666 solid; text-align: center; font-size: 24px; } img { width:300px; height:125px; }

  10. JavaScript source window.onload = rotate; var imagini = new Array("gb.jpg","biso.jpg","plib1.jpg","plib2.jpg"); var loc = 0; function rotate() { loc = (loc + 1) % imagini.length; document.getElementById("poze").src = imagini[loc]; setTimeout("rotate()", 1000); }

  11. Exemplu XML <?xml version="1.0" encoding="ISO-8859-1"?> <!DOCTYPE biblioteca SYSTEM "biblioteca.dtd“><!-- Valabil la DTD --> <biblioteca><!-- Valabil la DTD --> <!--biblioteca xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="biblioteca.xsd"--><!-- Valabil la XSD --> <nume>Biblioteca personala</nume> <domeniu> <nume>Informatica</nume> <carte isbn="973-97535-5-8"> <titlu>De la aritmetica la calculatoare</titlu> <autor>Boian Florian</autor> </carte> <carte isbn="978-1-594-96-544-9"> <titlu>AJAX in lectii de 10 minute</titlu><autor>Ballard Phill</autor> </carte> </domeniu> <domeniu> <nume>Poezie</nume> <carte isbn="973-95660-2-2"> <titlu>Poezii</titlu> <autor>Octavian Goga</autor> </carte> </domeniu> <domeniu> <nume>Sanscrita veche</nume> </domeniu> </biblioteca>

  12. XML definitions (1) Tag de început: <nume [atr1="val1" . . . atrn="valn" ]> Tag de sfârşit: </nume> Tag scurt (tag vid): <nume [atr1="val1" . . . atrn="valn" ]/> Element: <nume [atr1="val1" . . . atrn="valn" ]> Continut </nume>

  13. XML definitions (2) Well formed XML Valid XML Root tag Escapes: <> " &&lt; &gt; &quot; &amp; <> " &&#60; &62; &34; &38; <![CDATA[ şir de caractere ignorat de parserul XML ]]>

  14. XML definitions (3): namespaces default, explicit Default: <tagRoot xmlns="URI_definire_spatiu_de_nume"> Explicit: <prefix:tagRoot xmlns:prefix="URI_definire_spatiu_de_nume"> Example: <definitions name="ProductService" targetNamespace="http://www.ecerami.com/wsdl/ProductService.wsdl" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://www.ecerami.com/wsdl/ProductService.wsdl" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsd1="http://www.ecerami.com/schema"> Use: <prefix:nume … > - - - </prefix:nume>

  15. DTD (Data Type Definition) <!ELEMENT biblioteca (nume,domeniu+)> <!ELEMENT domeniu (nume,carte*)> <!ELEMENT nume (#PCDATA)> <!ELEMENT carte (titlu,autor)> <!ELEMENT titlu (#PCDATA)> <!ELEMENT autor (#PCDATA)> <!ELEMENT isbn (#PCDATA)> <!ATTLIST carte isbn CDATA "0">

  16. XML Schema <?xml version="1.0" encoding="ISO-8859-1"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:complexType name="TipCarte"> <xs:sequence> <xs:element name="titlu" type="xs:string"/> <xs:element name="autor" type="xs:string"/> </xs:sequence> <xs:attribute name="isbn" type="xs:string"/> </xs:complexType> <xs:complexType name="TipDomeniu"> <xs:sequence> <xs:element name="nume" type="xs:string"/> <xs:element name="carte" type="TipCarte" minOccurs="0" maxOccurs="unbounded"/> </xs:sequence> </xs:complexType> <xs:complexType name="TipBiblioteca"> <xs:sequence> <xs:element name="nume" type="xs:string"/> <xs:element name="domeniu" type="TipDomeniu" minOccurs="1" maxOccurs="unbounded"/> </xs:sequence> </xs:complexType> <xs:element name="biblioteca" type="TipBiblioteca"/> </xs:schema>

  17. XSLT (eXtensible Stylesheet Language family Transformations) <html xsl:version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <head><title>Lista biblioteci</title></head> <body><table border="1"> <xsl:for-each select="biblioteca/domeniu"> <tr><td colspan="2"><center><em> <xsl:value-of select="nume"/> </em></center></td></tr> <xsl:for-each select="carte"> <tr> <td><xsl:value-of select="titlu"/></td> <td><xsl:value-of select="autor"/></td> </tr> </xsl:for-each> </xsl:for-each> </table></body> </html> <?xml version="1.0" encoding="ISO-8859-1"?> <!DOCTYPE biblioteca SYSTEM "biblioteca.dtd">  se va insera linia de indicare a transformării, adică: <?xml version="1.0" encoding="ISO-8859-1"?> <?xml-stylesheet type="text/xsl" href="biblioteca.xsl"?> <!DOCTYPE biblioteca SYSTEM "biblioteca.dtd">

  18. Efect XSTL

  19. Parse SAX Python import xml.sax import xml.sax.handler import sys class Sax (xml.sax.handler.ContentHandler):   def __init__(self, isbn): self.isIsbn = 0 self.isTitlu = 0 self.isbn = isbn sp = xml.sax.make_parser() sp.setContentHandler(self) sp.parse("biblioteca.xml")   def startElement(self, qName, attributes): if qName == "carte": if attributes["isbn"] == self.isbn: self.isIsbn = 1 elif self.isIsbn == 1 and qName == "titlu" : self.isTitlu = 1   def characters(self, ch): if self.isTitlu == 1: print ch self.isTitlu = 0 self.isIsbn = 0 sax = Sax(sys.argv[1])

  20. Parse DOM Python import xml.dom.minidom from xml.dom.minidom import Node import sys class Dom(): def __init__(self, isbn): document = xml.dom.minidom.parse("biblioteca.xml") for carte in document.getElementsByTagName("carte"): if not carte.getAttribute("isbn") == isbn: continue titlu = carte.getElementsByTagName("titlu")[0] for node in titlu.childNodes: if not node.nodeType == Node.TEXT_NODE: continue print node.data break dom = Dom(sys.argv[1])

  21. Exemple de parsari XML:

  22. JSON (1) { "nume": "Biblioteca personala", "domeniu": [ { "nume": "Informatica", "carte": [ { "isbn": "973-97535-5-8", "titlu": "De la aritmetica la calculatoare", "autor": "Boian Florian" }, { "isbn": "978-1-594-96-544-9", "titlu": "AJAX in lectii de 10 minute", "autor": "Ballard Phill" } ] }, { "nume": "Poezie", "carte": [ { "isbn": "973-95660-2-2", "titlu": "Poezii", "autor": "Octavian Goga" } ] }, { "nume": "Sanscrita veche", "carte": [ ] } ]}

  23. JSON (2) Număr – întreg sau flotant; String – şir cuprins între ghilimele, iar caracterele speciale din şir sunt evitate folosind '\'; Boolean – valorile true şi false; null; Obiect – colecţie neordonată cuprinsă între ghilimele ({ . . . }), de perechi nume: valoare, separate prin virgulă; Array – colecţie ordonată cuprinsă între paranteze drepte ([ . . . ]) de valori separate prin virgulă; Escapes: \” \\ \/ \b \f \n \r \t \uhhhh

  24. Sintaxa JSON (1)

  25. Sintaxa JSON (2)

  26. Processing JSON import json import sys class Json:   def __init__(self, isbn): continut = "" fd = open("biblioteca.json") while 1: linie = fd.readline() if not linie: break continut += linie.strip() fd.close() document = json.loads(continut) for domeniu in document["domeniu"]: for carte in domeniu["carte"]: if not carte["isbn"] == isbn: continue print carte["titlu"]  j = Json(sys.argv[1])

  27. Exemple de procesari JSON

  28. Transport de resurse (trazactie) HTTP • In plus, HTTP/1.1: • Acceptarea de cereri şi răspunsuri pe fragmente (chunks).folosind "subtranzacţii". • Suport pentru stabilirea de conexiune permanentă cu mai multe cereri pe conexiune. • Filtrarea resurselor solicitate:If-Modified-Since şi If-Unmodified-Since.

  29. Cerere si raspuns HTTP POST /cgi-bin/Cgi.cgi HTTP/1.1 Accept: text/plain, text/html, image/gif, image/x-xbitmap, image/jpeg From: nustiucine@nicideunde.com Accept-Language: ro Accept-Encoding: gzip, deflate User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0) Host: florin:80 Connection: Keep-Alive Login=unUserOarecare&Password%3A=oParolaInClar HTTP/1.1 200 OK Server: Microsoft IIS/4.0 Date: Mon, 24 Nov 2003 11:07:32 GMT Content-type: text/html Last Modified: Sun, 23 Nov 2003 11:07:32 GMT Content-Length: 77 <HTML> <HEAD><TITLE>Prima pagina</TITLE></HEAD> <BODY>Salut</BODY> </HTML>

  30. Prima linie cerere, prima linie raspuns • <NumeMetoda> <CaleSauURL> <VersiuneHTTP> • GET /cale/spre/fisier/index.html HTTP/1.0 • GET /cale/spre/fisier/index.html HTTP/1.1 • GET http://www.cs.ubbcluj.ro/home/studenti/note.html HTTP/1.1 • POST /cgi-bin/Cgi.cgi HTTP/1.1 • <VersiuneHTTP> <CodRăspuns> <StringRăspuns> • HTTP/1.0 200 OK • HTTP/1.1 200 OK • HTTP/1.0 404 Not Found • HTTP/1.1 100 Continue • HTTP/1.1 304 Not Modified • HTTP/1.1 500 Server Error • HTTP/1.1 501 Not Implemented • CodRăspuns, categorii: • 1XX indică numai mesaje de informare. • 2XX indică mesaje de succes. • 3XX indică redirectarea clientului către un alt URL. • 4XX indică erori pe partea de client. • 5XX indică erori pe partea de server.

  31. HTTP headere

  32. HTTP MIME types

  33. HTTP Methods

  34. HTTP: prezentare generala ?

  35. TITLU

More Related