How to decode a http request packet with okio/okhttp
up vote
0
down vote
favorite
Can I use Okio and/or OkHTTP to decode a packet read from ParcelFileDescriptor ?
I'm trying to write a VpnService
based ad-blocker on android.
I've found a few open source projects using VpnService
(NetGuard, NetKnight), so I could learn from them.
And I known OkHTTP could make a request using just url
and method
, which means it could understood some thing like GET http://stackoverflow.com Http/1.1
, and transform it to a real TCP/IP based request, even decode response. So I tried to read some source code of Okio to found out what it does, but failed.
So I was wondering if I could use Okio's component to decode/encode TCP/IP packets?
android vpn okhttp okio
add a comment |
up vote
0
down vote
favorite
Can I use Okio and/or OkHTTP to decode a packet read from ParcelFileDescriptor ?
I'm trying to write a VpnService
based ad-blocker on android.
I've found a few open source projects using VpnService
(NetGuard, NetKnight), so I could learn from them.
And I known OkHTTP could make a request using just url
and method
, which means it could understood some thing like GET http://stackoverflow.com Http/1.1
, and transform it to a real TCP/IP based request, even decode response. So I tried to read some source code of Okio to found out what it does, but failed.
So I was wondering if I could use Okio's component to decode/encode TCP/IP packets?
android vpn okhttp okio
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
Can I use Okio and/or OkHTTP to decode a packet read from ParcelFileDescriptor ?
I'm trying to write a VpnService
based ad-blocker on android.
I've found a few open source projects using VpnService
(NetGuard, NetKnight), so I could learn from them.
And I known OkHTTP could make a request using just url
and method
, which means it could understood some thing like GET http://stackoverflow.com Http/1.1
, and transform it to a real TCP/IP based request, even decode response. So I tried to read some source code of Okio to found out what it does, but failed.
So I was wondering if I could use Okio's component to decode/encode TCP/IP packets?
android vpn okhttp okio
Can I use Okio and/or OkHTTP to decode a packet read from ParcelFileDescriptor ?
I'm trying to write a VpnService
based ad-blocker on android.
I've found a few open source projects using VpnService
(NetGuard, NetKnight), so I could learn from them.
And I known OkHTTP could make a request using just url
and method
, which means it could understood some thing like GET http://stackoverflow.com Http/1.1
, and transform it to a real TCP/IP based request, even decode response. So I tried to read some source code of Okio to found out what it does, but failed.
So I was wondering if I could use Okio's component to decode/encode TCP/IP packets?
android vpn okhttp okio
android vpn okhttp okio
asked Nov 22 at 16:10
XieEDeHeiShou
958
958
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
Yes. Create a Socket using the normal APIs, then use Okio.source(Socket)
and Okio.sink(Socket)
to get streams from it. Also don't forget that you can buffer these streams with Okio.buffer()
.
How's the socket come from? The VpnService returned with a ParcelFileDescriptor.
– XieEDeHeiShou
Nov 23 at 2:19
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
Yes. Create a Socket using the normal APIs, then use Okio.source(Socket)
and Okio.sink(Socket)
to get streams from it. Also don't forget that you can buffer these streams with Okio.buffer()
.
How's the socket come from? The VpnService returned with a ParcelFileDescriptor.
– XieEDeHeiShou
Nov 23 at 2:19
add a comment |
up vote
0
down vote
Yes. Create a Socket using the normal APIs, then use Okio.source(Socket)
and Okio.sink(Socket)
to get streams from it. Also don't forget that you can buffer these streams with Okio.buffer()
.
How's the socket come from? The VpnService returned with a ParcelFileDescriptor.
– XieEDeHeiShou
Nov 23 at 2:19
add a comment |
up vote
0
down vote
up vote
0
down vote
Yes. Create a Socket using the normal APIs, then use Okio.source(Socket)
and Okio.sink(Socket)
to get streams from it. Also don't forget that you can buffer these streams with Okio.buffer()
.
Yes. Create a Socket using the normal APIs, then use Okio.source(Socket)
and Okio.sink(Socket)
to get streams from it. Also don't forget that you can buffer these streams with Okio.buffer()
.
answered Nov 23 at 1:13
Jesse Wilson
24.1k26884
24.1k26884
How's the socket come from? The VpnService returned with a ParcelFileDescriptor.
– XieEDeHeiShou
Nov 23 at 2:19
add a comment |
How's the socket come from? The VpnService returned with a ParcelFileDescriptor.
– XieEDeHeiShou
Nov 23 at 2:19
How's the socket come from? The VpnService returned with a ParcelFileDescriptor.
– XieEDeHeiShou
Nov 23 at 2:19
How's the socket come from? The VpnService returned with a ParcelFileDescriptor.
– XieEDeHeiShou
Nov 23 at 2:19
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53434765%2fhow-to-decode-a-http-request-packet-with-okio-okhttp%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown