|
View:
New views
2 Messages
—
Rating Filter:
Alert me
|
|
|
Squid redirector not working with "?" in urlI configured squid to use redirector behind another squid proxy of our institute.
It is working fine when i am using it to redirect it to another constant url like http://www.google.com/ what i want to do is to redirect each request url as url+?mail, as the proxy server allows all connections of this type. But it is not working with the perl script #!/usr/bin/perl $|=1; while (<>) { @X = split; $url = $X[0]; print "$url\?mail\n"; } So , i thought that perl might not be working so i wrote an C program for this int main() { char s[200]; cin>>s; strcat(s,"\?mail"); cout<<s<<"\n"; } The redirector script work if i didnt add "\?mail" , actually its the question mark symbol due to which page is not loaded and it shows an error message of ERROR The requested URL could not be retrieved While trying to retrieve the URL: http://www.google.co.in/? The following error was encountered: * Connection to 74.125.65.104 Failed The system returned: (111) Connection refused The remote host or network may be down. Please try the request again. Your cache administrator is webmaster. Generated Sat, 31 Oct 2009 22:23:22 GMT by spark (squid/2.7.STABLE3) I think its the question mark character which is preventing it from loading as the page loads if i remove the question mark symbol and add only some character string like "mail". How can i remove this... Thanks |
|
|
Re: Squid redirector not working with "?" in urllör 2009-10-31 klockan 15:32 -0700 skrev nitinnitin18:
> I configured squid to use redirector behind another squid proxy of our > institute. > It is working fine when i am using it to redirect it to another constant url > like http://www.google.com/ > what i want to do is to redirect each request url as url+?mail, as the proxy > server allows all connections > of this type. But it is not working with the perl script > > #!/usr/bin/perl > $|=1; > while (<>) { > @X = split; > $url = $X[0]; > print "$url\?mail\n"; > } > > So , i thought that perl might not be working so i wrote an C program for > this > > int main() > { > > char s[200]; > cin>>s; > strcat(s,"\?mail"); > cout<<s<<"\n"; > } These two are not the same. The C++ version has many errors in how it reads and processes the request, some fatal (2 buffer overflows), some just causing malfunction (improper reading & parsing of squid requests). using cin like this is very tricky. Better to read a line at a time and using string instead of char arrays. The following C++ should be equal to your perl: #include <string> #include <iostream> #include <sstream> using namespace std; int main() { string line; while ( getline(cin, line) ) { string url; istringstream split(line); split >> url; cout << url << "?mail\n" << flush; } } Regards Henrik |
| Free embeddable forum powered by Nabble | Forum Help |