Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chunking failure #11

Closed
orthecreedence opened this issue Dec 11, 2014 · 3 comments
Closed

Chunking failure #11

orthecreedence opened this issue Dec 11, 2014 · 3 comments

Comments

@orthecreedence
Copy link

Hello, I am getting

Expectation failed: NIL
   [Condition of type FAST-HTTP.PARSER::EXPECT-FAILED]

when doing the following:

(let* ((bytes (with-open-file (f "./chunk-test.http" :direction :input :element-type '(unsigned-byte 8))
                (let ((buff (make-array (file-length f) :element-type '(unsigned-byte 8))))
                  (read-sequence buff f)
                  buff)))
       (http (fast-http:make-http-response))
       (parser (fast-http:make-parser http)))
  (funcall parser (subseq bytes 0 1430))
  (funcall parser (subseq bytes 1430)))

chunk-test.http is as follows (also emailed you the binary version just in case it's a line-endings issue):

HTTP/1.1 200 OK

Date: Thu, 11 Dec 2014 18:39:15 GMT

Expires: -1

Cache-Control: private, max-age=0

Content-Type: text/html; charset=windows-1251

Set-Cookie: PREF=ID=714f975c931d0648:FF=0:TM=1418323155:LM=1418323155:S=gk9jV6JHg-YVFBsC; expires=Sat, 10-Dec-2016 18:39:15 GMT; path=/; domain=.google.com.ua

Set-Cookie: NID=67=X3L_r6qc87PRaACqn610x6iSD12rr6x6KQDHv7WkmpkKTwhPYPh7r21cLq3RG2rRlN3mwwMkzSlnd5Jw9kzZ_Lty3s8J0jtV4aN9PzXQAgPLokKrTFE5R9ZEb6N3yF4x; expires=Fri, 12-Jun-2015 18:39:15 GMT; path=/; domain=.google.com.ua; HttpOnly

P3P: CP="This is not a P3P policy! See http://www.google.com/support/accounts/bin/answer.py?hl=en&answer=151657 for more info."

Server: gws

X-XSS-Protection: 1; mode=block

X-Frame-Options: SAMEORIGIN

Alternate-Protocol: 80:quic,p=0.02

Transfer-Encoding: chunked



473b

<!doctype html><html itemscope="" itemtype="http://schema.org/WebPage" lang="uk"><head><meta content="/images/google_favicon_128.png" itemprop="image"><title>Google</title><script>(function(){window.google={kEI:'0-SJVNmWC5W4ogSlvYL4Aw',kEXPI:'4010073,4011559,4013920,4016824,4017578,4020110,4020347,4020562,4021587,4021598,4023566,4024625,4025103,4025170,4025743,4025769,4025828,4026540,4027041,4027316,8500394,8500851,8500923,10200083,10200716,10200743,10200765,10200835,10200838,10200876',authuser:0,kSID:'0-SJVNmWC5W4ogSlvYL4Aw'};google.kHL='uk';})();(function(){google.lc=[];google.li=0;google.getEI=function(a){for(var b;a&&(!a.getAttribute||!(b=a.getAttribute("eid")));)a=a.parentNode;return b||google.kEI};google.https=function(){return"https:"==window.location.protocol};google.ml=function(){};google.time=function(){return(new Date).getTime()};google.log=function(a,b,d,e,k){var c=new Image,h=google.lc,f=google.li,g="",l=google.ls||"";c.onerror=c.onload=c.onabort=function(){delete h[f]};h[f]=c;d||-1!=b.search("&ei=")||(e=google.getEI(e),g="&ei="+e,e!=google.kEI&&(g+="&lei="+google.kEI));a=d||"/"+(k||"gen_204")+"?atyp=i&ct="+a+"&cad="+b+g+l+"&zx="+google.time();/^http:/i.test(a)&&google.https()?(google.ml(Error("a"),!1,{src:a,glmm:1}),delete h[f]):(c.src=a,google.li=f+1)};google.y={};google.x=function(a,b){google.y[a.id]=[a,b];return!1};google.load=function(a,b,d){google.x({id:a+m++},function(){google.load(a,b,d)})};var m=0;})();google.kCSI={};var _gjwl=location;function _gjuc(){var a=_gjwl.href.indexOf("#");if(0<=a&&(a=_gjwl.href.substring(a),0<a.indexOf("&q=")||0<=a.indexOf("#q="))&&(a=a.substring(1),-1==a.indexOf("#"))){for(var d=0;d<a.length;){var b=d;"&"==a.charAt(b)&&++b;var c=a.indexOf("&",b);-1==c&&(c=a.length);b=a.substring(b,c);if(0==b.indexOf("fp="))a=a.substring(0,d)+a.substring(c,a.length),c=d;else if("cad=h"==b)return 0;d=c}_gjwl.href="/search?"+a+"&cad=h";return 1}return 0}
function _gjh(){!_gjuc()&&window.google&&google.x&&google.x({id:"GJH"},function(){google.nav&&google.nav.gjh&&google.nav.gjh()})}
@orthecreedence
Copy link
Author

Oh, just realized an easier test case (using the latest version of carrier/cl-async):

(ql:quickload '(:cl-async :blackbird :carrier))
(defun chunk-test ()
  (as:with-event-loop ()
    (bb:wait (carrier:request "http://www.google.com.ua")
      (format t "done.~%"))))

@fukamachi
Copy link
Owner

Thank you for reporting!

Actually, it was a quite clear bug when parsing a chunked body. I think the above commit fixes it.

@orthecreedence
Copy link
Author

Works great now, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants