phimage / Erik

Erik is an headless browser based on WebKit. An headless browser allow to run functional tests, to access and manipulate webpages using javascript.
http://phimage.github.io/Erik/
MIT License
596 stars 47 forks source link

How to get the response headers? #27

Closed xia0ta0 closed 7 years ago

xia0ta0 commented 7 years ago

I am using visit() to crawl a webpage, but how to get the HTTP response headers?

Thanks.

phimage commented 7 years ago

I use wkwebview and I think the only way to get headers is to implement the delegate

see https://stackoverflow.com/questions/41128709/retrieve-http-response-headers-from-wkwebview

and to access the internal wkwebview there is cast

let engine = Erik.sharedInstance.layoutEngine as? WebKitLayoutEngine
xia0ta0 commented 7 years ago

OK, I got it. Thank you!