{"id":10,"date":"2015-08-29T14:59:26","date_gmt":"2015-08-29T12:59:26","guid":{"rendered":"http:\/\/www.underealm.com\/code\/?p=10"},"modified":"2015-08-29T14:59:26","modified_gmt":"2015-08-29T12:59:26","slug":"rfc7233-is-wrong","status":"publish","type":"post","link":"http:\/\/www.underealm.com\/code\/2015\/08\/rfc7233-is-wrong\/","title":{"rendered":"RFC 7233: So Wrong"},"content":{"rendered":"<p>Do you remember that one time (about 10 minutes ago) where I started double-checking <a href=\"https:\/\/tools.ietf.org\/html\/rfc7233#section-6.1\">RFC 7233<\/a> to make sure I was doing everything perfectly, and found out that the RFC is <strong>WRONG<\/strong>? There&#8217;s a first time for everything.<\/p>\n<p><code>HTTP\/1.1 206 Partial Content<br \/>\n     Date: Wed, 15 Nov 1995 06:25:24 GMT<br \/>\n     Last-Modified: Wed, 15 Nov 1995 04:58:08 GMT<br \/>\n     Content-Length: <strong>1741<\/strong><br \/>\n     Content-Type: multipart\/byteranges; boundary=THIS_STRING_SEPARATES<\/p>\n<p>     --THIS_STRING_SEPARATES<br \/>\n     Content-Type: application\/pdf<br \/>\n     Content-Range: bytes 500-999\/8000<\/p>\n<p>     ...the first range...<br \/>\n     --THIS_STRING_SEPARATES<br \/>\n     Content-Type: application\/pdf<br \/>\n     Content-Range: bytes 7000-7999\/8000<\/p>\n<p>     ...the second range<br \/>\n     --THIS_STRING_SEPARATES--<\/code><\/p>\n<p>After deep analysis (and lots of recalculations) I discovered that the RFC is incorrect and uses a wrong content length. Let&#8217;s sum it up:<\/p>\n<ol>\n<li>500 (500-999) + 1000 (7000-7999) bytes of pure content<\/li>\n<li>197 bytes of multipart boundaries and headers<\/li>\n<li>11 CR+LF (22 bytes)<\/li>\n<\/ol>\n<p>For a whopping total of <strong>1719<\/strong>. What&#8217;s left? 22 bytes. Or, maybe best put, 11 CR+LF. They counted them twice.<\/p>\n<p><strong>Bonus fact<\/strong>: this multipart example is also <strong>INVALID<\/strong> and might be rejected from strict clients. A leading CR+LF is considered part of the boundary, so the first boundary in the content should be separated by <strong>three<\/strong> CR+LF and not two.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Do you remember that one time (about 10 minutes ago) where I started double-checking RFC 7233 to make sure I was doing everything perfectly, and found out that the RFC is WRONG? There&#8217;s a first time for everything. HTTP\/1.1 206 Partial Content Date: Wed, 15 Nov 1995 06:25:24 GMT Last-Modified: Wed, 15 Nov 1995 04:58:08 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[13,11,12,14,10,7,9,8],"class_list":["post-10","post","type-post","status-publish","format-standard","hentry","category-programming","tag-13","tag-byteranges","tag-http","tag-http-206","tag-multipart","tag-rfc","tag-rfc-7233","tag-rfc7233"],"jetpack_featured_media_url":"","_links":{"self":[{"href":"http:\/\/www.underealm.com\/code\/wp-json\/wp\/v2\/posts\/10"}],"collection":[{"href":"http:\/\/www.underealm.com\/code\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.underealm.com\/code\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.underealm.com\/code\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.underealm.com\/code\/wp-json\/wp\/v2\/comments?post=10"}],"version-history":[{"count":0,"href":"http:\/\/www.underealm.com\/code\/wp-json\/wp\/v2\/posts\/10\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.underealm.com\/code\/wp-json\/wp\/v2\/media?parent=10"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.underealm.com\/code\/wp-json\/wp\/v2\/categories?post=10"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.underealm.com\/code\/wp-json\/wp\/v2\/tags?post=10"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}