BrowserFlow in NetworkExtensions

I am using NEfilterdata class to get the NEfilterflow and converting it into browserflow. I am not getting the data in browserflow at first time loading the website but gettiing the data on second time loading the website.

Thats why my filtering logic only applies when i reload the page not on first time usage.



guard let browserFlow : NEFilterBrowserFlow = flow as? NEFilterBrowserFlow

else { return NEFilterDataVerdict.init(passBytes: readBytes.count, peekBytes: 10000000) }

Replies

Are you sure this request hit the ‘wire’? It’s not uncommon for web pages to be cached for a long time, and thus loading a page doesn’t actually involve a request to the origin server. Hitting reload, however, will force such a request.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

NEfilterflow object is getting data, but when i try to covert it into NEbrowserflow, it hits the gaurd else statement.

That means we are getting the flow. So it might not be the problem of caching.

This problem is only for first time loading the webpage not on second time.

I’m sorry but I don’t understand what you’ve written here. It sounds like you’ve got an

NEFilterFlow
and you’re trying to cast it to an
NEFilterBrowserFlow
and that cast is failing. If that’s the case then it’s likely that the flow is actually a socket flow (
NEFilterSocketFlow
). Try casting to that and see what you get.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

Thanks Quinn,

I got that, By the way is there a way to get mimetype through socket flow, i am not seeing any variables corresponding to mimetype in socketflow that i see in brwoserflow.

else how can u get mimetype from data coming in


handleInboundData(from flow: NEFilterFlow, readBytesStartOffset offset: Int, readBytes: Data)

i am not seeing any variables corresponding to mimetype in socketflow that i see in brwoserflow.

Right. In situations where you get a socket flow the system simply doesn’t have access to that extra information.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

Hey Himesh,

Were you able to resolve your issue? I'm working on a similar scenario and trying to use NEFilterBrowserFlow.


Would love to get some tips on how to get NEFilterBrowserFlow to get access to HTML/CSS in real-time. Here's my question - https://forums.developer.apple.com/thread/116043


If you are up for a discussion over a call, I'd love that.



cheers

Arun