go ahead... be a heretic | |
PerlMonks |
User-Agent in LWP::UserAgentby msel (Initiate) |
on Aug 13, 2014 at 03:41 UTC ( [id://1097212]=perlquestion: print w/replies, xml ) | Need Help?? |
msel has asked for the wisdom of the Perl Monks concerning the following question: Hello, I am trying to rewrite the User-Agent header using the request_preprepare handler. For testing purposes, I have a webserver set up that redirects / to /dog, /dog to /cat, and /cat to /cat/. I have the following code:
Running the above results in the following output: User-Agent: TEST 0User-Agent: TEST 1 User-Agent: TEST 2 User-Agent: TEST 3 But the webserver log show the following: 127.0.0.1 - - 12/Aug/2014:23:06:09 -0400 "GET / HTTP/1.1" 302 204 "-" "TEST 0" 127.0.0.1 - - 12/Aug/2014:23:06:09 -0400 "GET /dog HTTP/1.1" 302 204 "-" "TEST 0" 127.0.0.1 - - 12/Aug/2014:23:06:09 -0400 "GET /cat HTTP/1.1" 302 205 "-" "TEST 0" 127.0.0.1 - - 12/Aug/2014:23:06:09 -0400 "GET /cat/ HTTP/1.1" 200 669 "-" "TEST 0" It sets "TEST 0" as the initial User-Agent for the request for / (correctly replacing "BOGUS"), but it never increments for /dog, /cat, or /cat/ although it appears the handler is being called. What am I doing wrong? I can make this work by setting max_redirects to 0 and doing the redirect work manually by creating new LWP::UserAgent objects, but that is less elegant. Thanks!
Back to
Seekers of Perl Wisdom
|
|