SlideShare una empresa de Scribd logo
1 de 15
MXHR技术探究
 (Multipart Xml Http Request)




                                 http://github.com/xiaojue
                                http://twitter.com/xiao_jue
Multipart Content-Type


                 MIME (Multipurpose Internet Mail Extensions)


                 IETF (Internet Engineering Task Force)


                 RFC (Request for Comments)


                 text/html html
                 text/css css
                 image/x-icon ico
                 image/jpeg jpeg



Content-type: multipart/mixed; boundary="simple boundary"
multipart-body := preamble 1*encapsulation close-delimiter epilogue

encapsulation := delimiter CRLF body-part

delimiter := CRLF "--" boundary ; taken from Content-Type field.
                   ; when content-type is multipart
                 ; There must be no space
                 ; between "--" and boundary.

close-delimiter := delimiter "--" ; Again, no space before "--"

preamble := *text ; to be ignored upon receipt.

epilogue := *text ; to be ignored upon receipt.

body-part = <"message" as defined in RFC 822,
    with all header fields optional, and with the
    specified delimiter not occurring anywhere in
    the message body, either on a line by itself
    or as a substring anywhere. Note that the
                                                                  Backus-Naur Form (BNF) 是一种描述语
    semantics of a part differ from the semantics                 法的方法,比如 ACL 语法。它通常用
    of a message, as described in the text.>                      于开发 Internet 协议,因为 BNF 十分
                                                                  简洁而且非常准确。

http://www.w3.org/Protocols/rfc1341/7_2_Multipart.html
usage scenario
      MTA(Mail Transport Agent)
    From: Nathaniel Borenstein <nsb@bellcore.com>
       To: Ned Freed <ned@innosoft.com>
       Subject: Sample message
       MIME-Version: 1.0
       Content-type: multipart/mixed; boundary="simple boundary"

      This is the preamble. It is to be ignored, though it
      is a handy place for mail composers to include an
      explanatory note to non-MIME compliant readers.
      --simple boundary

      This is implicitly typed plain ASCII text.
      It does NOT end with a linebreak.
      --simple boundary
      Content-type: text/plain; charset=us-ascii

      This is explicitly typed plain ASCII text.
      It DOES end with a linebreak.

      --simple boundary--
      This is the epilogue. It is also to be ignored.
As3 Loader …

         Socket io…


Server                                         client
                      http...




          Ajax…

                                  Jsonp…
               Mxhr
combine
Nginx concat combo,PHP Minify

Local Package

Cssjs merge

mxhr
http://site.douban.com/widget/notes/6513752/note/197185582/



XMLHttpRequest

Perfect?
Digg                                 Request:
                                       var template;
                                       $.mxhr({
                                          url: '/fictonal/bsg/endpoint.mxhr',
                                          type: 'GET',
                                          'text/html': function(data) {
                                             template = data;
                                          },
                                          'application/json': function(data) {
                                             view = $.parseJSON(data);
                                             console.log(Mustache.to_html(template, view));
                                          }
                                       });

                                       Response:
                                       --|||
                                       Content-Type: text/html
                                       Hello {{world}}.
                                       --|||
                                       Content-Type: application/json
                                       {"world": "New Caprica"}
                                       --|||--


https://github.com/dfltr/jQuery-MXHR
•   'MSXML2.XMLHTTP.6.0',
    'MSXML3.XMLHTTP',
    'Microsoft.XMLHTTP', // Doesn't support readyState == 3 header requests.
    'MSXML2.XMLHTTP.3.0', // Doesn't support readyState == 3 header requests.

•   Ie6,7,8 dDoesn’t support data:url
IE6,7,8 support flashplayer




DATA:URL in ie6,(7,8)?


pass back ?
As decode?
Clinet PNG Analyzer?
MXHR IN ACTION
https://github.com/xiaojue/mxhrmanager
Q&A
Mxhr

Más contenido relacionado

Similar a Mxhr

HTTP::Parser::XS - writing a fast & secure XS module
HTTP::Parser::XS - writing a fast & secure XS moduleHTTP::Parser::XS - writing a fast & secure XS module
HTTP::Parser::XS - writing a fast & secure XS module
Kazuho Oku
 
Javascript session 01 - Introduction to Javascript
Javascript session 01 - Introduction to JavascriptJavascript session 01 - Introduction to Javascript
Javascript session 01 - Introduction to Javascript
Livingston Samuel
 
Consuming RESTful services in PHP
Consuming RESTful services in PHPConsuming RESTful services in PHP
Consuming RESTful services in PHP
Zoran Jeremic
 
Implementing WebServices with Camel and CXF in ServiceMix
Implementing WebServices with Camel and CXF in ServiceMixImplementing WebServices with Camel and CXF in ServiceMix
Implementing WebServices with Camel and CXF in ServiceMix
Adrian Trenaman
 
Introduction to Thrift
Introduction to ThriftIntroduction to Thrift
Introduction to Thrift
Dvir Volk
 
The Magic Revealed: Four Real-World Examples of Using the Client Object Model...
The Magic Revealed: Four Real-World Examples of Using the Client Object Model...The Magic Revealed: Four Real-World Examples of Using the Client Object Model...
The Magic Revealed: Four Real-World Examples of Using the Client Object Model...
SPTechCon
 
Nodejs 프로그래밍 ch.3
Nodejs 프로그래밍 ch.3Nodejs 프로그래밍 ch.3
Nodejs 프로그래밍 ch.3
HyeonSeok Choi
 

Similar a Mxhr (20)

HTTP::Parser::XS - writing a fast & secure XS module
HTTP::Parser::XS - writing a fast & secure XS moduleHTTP::Parser::XS - writing a fast & secure XS module
HTTP::Parser::XS - writing a fast & secure XS module
 
Rapid java backend and api development for mobile devices
Rapid java backend and api development for mobile devicesRapid java backend and api development for mobile devices
Rapid java backend and api development for mobile devices
 
Javascript session 01 - Introduction to Javascript
Javascript session 01 - Introduction to JavascriptJavascript session 01 - Introduction to Javascript
Javascript session 01 - Introduction to Javascript
 
Aspdotnet
AspdotnetAspdotnet
Aspdotnet
 
Synapseindia dot net development web applications with ajax
Synapseindia dot net development  web applications with ajaxSynapseindia dot net development  web applications with ajax
Synapseindia dot net development web applications with ajax
 
Consuming RESTful Web services in PHP
Consuming RESTful Web services in PHPConsuming RESTful Web services in PHP
Consuming RESTful Web services in PHP
 
Consuming RESTful services in PHP
Consuming RESTful services in PHPConsuming RESTful services in PHP
Consuming RESTful services in PHP
 
Instant YANG - Tail-f Systems Technology Primer
Instant YANG - Tail-f Systems Technology PrimerInstant YANG - Tail-f Systems Technology Primer
Instant YANG - Tail-f Systems Technology Primer
 
Implementing WebServices with Camel and CXF in ServiceMix
Implementing WebServices with Camel and CXF in ServiceMixImplementing WebServices with Camel and CXF in ServiceMix
Implementing WebServices with Camel and CXF in ServiceMix
 
Ajax xml json
Ajax xml jsonAjax xml json
Ajax xml json
 
Xml writers
Xml writersXml writers
Xml writers
 
IBM dwLive, "Internet & HTTP - 잃어버린 패킷을 찾아서..."
IBM dwLive, "Internet & HTTP - 잃어버린 패킷을 찾아서..."IBM dwLive, "Internet & HTTP - 잃어버린 패킷을 찾아서..."
IBM dwLive, "Internet & HTTP - 잃어버린 패킷을 찾아서..."
 
Server Side JavaScript: Ajax.org O3
Server Side JavaScript: Ajax.org O3Server Side JavaScript: Ajax.org O3
Server Side JavaScript: Ajax.org O3
 
Server Side JavaScript: Ajax.org O3.
Server Side JavaScript: Ajax.org O3.Server Side JavaScript: Ajax.org O3.
Server Side JavaScript: Ajax.org O3.
 
Introduction to Thrift
Introduction to ThriftIntroduction to Thrift
Introduction to Thrift
 
jkljklj
jkljkljjkljklj
jkljklj
 
The Magic Revealed: Four Real-World Examples of Using the Client Object Model...
The Magic Revealed: Four Real-World Examples of Using the Client Object Model...The Magic Revealed: Four Real-World Examples of Using the Client Object Model...
The Magic Revealed: Four Real-World Examples of Using the Client Object Model...
 
Web Server and how we can design app in C#
Web Server and how we can design app  in C#Web Server and how we can design app  in C#
Web Server and how we can design app in C#
 
Developing Realtime Data Pipelines With Apache Kafka
Developing Realtime Data Pipelines With Apache KafkaDeveloping Realtime Data Pipelines With Apache Kafka
Developing Realtime Data Pipelines With Apache Kafka
 
Nodejs 프로그래밍 ch.3
Nodejs 프로그래밍 ch.3Nodejs 프로그래밍 ch.3
Nodejs 프로그래밍 ch.3
 

Más de xiaojueqq12345 (6)

前端模块化开发
前端模块化开发前端模块化开发
前端模块化开发
 
Fds-给前端用的服务器
Fds-给前端用的服务器Fds-给前端用的服务器
Fds-给前端用的服务器
 
Voluminous_Weibo
Voluminous_WeiboVoluminous_Weibo
Voluminous_Weibo
 
Lithe
LitheLithe
Lithe
 
nodejs开发web站点
nodejs开发web站点nodejs开发web站点
nodejs开发web站点
 
Web program-peformance-optimization
Web program-peformance-optimizationWeb program-peformance-optimization
Web program-peformance-optimization
 

Último

+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...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Último (20)

HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
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...
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
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
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
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
 
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
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
+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...
 
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
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 

Mxhr

  • 1. MXHR技术探究 (Multipart Xml Http Request) http://github.com/xiaojue http://twitter.com/xiao_jue
  • 2. Multipart Content-Type MIME (Multipurpose Internet Mail Extensions) IETF (Internet Engineering Task Force) RFC (Request for Comments) text/html html text/css css image/x-icon ico image/jpeg jpeg Content-type: multipart/mixed; boundary="simple boundary"
  • 3. multipart-body := preamble 1*encapsulation close-delimiter epilogue encapsulation := delimiter CRLF body-part delimiter := CRLF "--" boundary ; taken from Content-Type field. ; when content-type is multipart ; There must be no space ; between "--" and boundary. close-delimiter := delimiter "--" ; Again, no space before "--" preamble := *text ; to be ignored upon receipt. epilogue := *text ; to be ignored upon receipt. body-part = <"message" as defined in RFC 822, with all header fields optional, and with the specified delimiter not occurring anywhere in the message body, either on a line by itself or as a substring anywhere. Note that the Backus-Naur Form (BNF) 是一种描述语 semantics of a part differ from the semantics 法的方法,比如 ACL 语法。它通常用 of a message, as described in the text.> 于开发 Internet 协议,因为 BNF 十分 简洁而且非常准确。 http://www.w3.org/Protocols/rfc1341/7_2_Multipart.html
  • 4. usage scenario MTA(Mail Transport Agent) From: Nathaniel Borenstein <nsb@bellcore.com> To: Ned Freed <ned@innosoft.com> Subject: Sample message MIME-Version: 1.0 Content-type: multipart/mixed; boundary="simple boundary" This is the preamble. It is to be ignored, though it is a handy place for mail composers to include an explanatory note to non-MIME compliant readers. --simple boundary This is implicitly typed plain ASCII text. It does NOT end with a linebreak. --simple boundary Content-type: text/plain; charset=us-ascii This is explicitly typed plain ASCII text. It DOES end with a linebreak. --simple boundary-- This is the epilogue. It is also to be ignored.
  • 5. As3 Loader … Socket io… Server client http... Ajax… Jsonp… Mxhr
  • 6. combine Nginx concat combo,PHP Minify Local Package Cssjs merge mxhr
  • 8. Digg Request: var template; $.mxhr({ url: '/fictonal/bsg/endpoint.mxhr', type: 'GET', 'text/html': function(data) { template = data; }, 'application/json': function(data) { view = $.parseJSON(data); console.log(Mustache.to_html(template, view)); } }); Response: --||| Content-Type: text/html Hello {{world}}. --||| Content-Type: application/json {"world": "New Caprica"} --|||-- https://github.com/dfltr/jQuery-MXHR
  • 9.
  • 10. 'MSXML2.XMLHTTP.6.0', 'MSXML3.XMLHTTP', 'Microsoft.XMLHTTP', // Doesn't support readyState == 3 header requests. 'MSXML2.XMLHTTP.3.0', // Doesn't support readyState == 3 header requests. • Ie6,7,8 dDoesn’t support data:url
  • 11. IE6,7,8 support flashplayer DATA:URL in ie6,(7,8)? pass back ? As decode? Clinet PNG Analyzer?
  • 14. Q&A