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

How to change the HTTP Header? #105

Open
Mapaler opened this issue Jul 28, 2017 · 2 comments
Open

How to change the HTTP Header? #105

Mapaler opened this issue Jul 28, 2017 · 2 comments

Comments

@Mapaler
Copy link

@Mapaler Mapaler commented Jul 28, 2017

My school, in order to make money, forbids students to share wired broadband with mobile phones.

I need to change "Android" in User-Agent to "Windows" to disguise computer access.
I used Fidder2‘s CustomRules.js - function OnBeforeRequest to replace all of the android in UA.
image 7
It takes a Windows computer to open all the time to run Fidder.

I try to setup a proxy on a router with OpenWrt. I install

I don't know how to partial replace "Android" , and I use "AddHeader", there are two User-Agent
image 2
image 3
image 5

@rofl0r

This comment has been minimized.

Copy link
Contributor

@rofl0r rofl0r commented Jul 29, 2017

try additionally this patch:

diff --git a/src/reqs.c b/src/reqs.c
index 990152a..7007335 100644
--- a/src/reqs.c
+++ b/src/reqs.c
@@ -598,7 +598,8 @@ add_header_to_connection (hashmap_t hashofheaders, char *header, size_t len)
 
         /* Calculate the new length of just the data */
         len -= sep - header - 1;
-
+       if(!strcmp(header, "User-Agent") && strstr("Android", sep))
+               return 0;
         return hashmap_insert (hashofheaders, header, sep, len);
 }

there is no built-in possibility to do what you want, but i guess it could be implemented as "ReplaceHeader"

@Mapaler

This comment has been minimized.

Copy link
Author

@Mapaler Mapaler commented Jul 29, 2017

Thanks, I'm not professional, don't know how to build to OpenWrt version.(I install at Package)
I think you can add a "RemoveHeader" , and then "RemoveHeader" + "AddHeader" = "ReplaceHeader"

I used Privoxy to solve my problem.
Add to user.action

# 替换Header里的安卓的行为,调用叫android的filter
{+client-header-filter{android}}
/

Add to user.filter

#把“Android”替换为“Windows NT”的filter
CLIENT-HEADER-FILTER: android Replace all "Android" with "Windows NT"

s@^(User-Agent:.*)\bWindows NT\b(.*)@$1Android$2@ig
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.