473,729 Members | 2,166 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

LWP with proxy problem

When running the sample code below without a proxy the GET returns the
expected data. When run with the $proxy uncommented the GET returns
the content of the login page for the site being accessed. The site
in the code is valid for ease of testing. I also am including the LWP
debug info for each attempt.

Can anyone explain this behavior and what can I do to correct it?

Thanks in advance

Trace without proxy:

LWP::UserAgent: :new: ()
LWP::UserAgent: :request: ()
LWP::UserAgent: :send_request: GET
https://squid.servebeer.com/getservi...ing&format=csv
LWP::UserAgent: :_need_proxy: Not proxied
LWP::Protocol:: http::request: ()
LWP::Protocol:: collect: read 28 bytes
LWP::UserAgent: :request: Simple response: OK

Home
PE
Trace with proxy:

LWP::UserAgent: :new: ()
LWP::UserAgent: :proxy: https http://148.245.207.85:8080
LWP::UserAgent: :request: ()
LWP::UserAgent: :send_request: GET
https://squid.servebeer.com/getservi...ing&format=csv
LWP::UserAgent: :_need_proxy: Proxied to http://148.245.207.85:8080
LWP::Protocol:: http::request: ()
LWP::Protocol:: collect: read 236 bytes
LWP::Protocol:: collect: read 594 bytes
LWP::Protocol:: collect: read 416 bytes
LWP::Protocol:: collect: read 450 bytes
LWP::Protocol:: collect: read 1017 bytes
LWP::Protocol:: collect: read 443 bytes
LWP::Protocol:: collect: read 643 bytes
LWP::UserAgent: :request: Simple response: OK

<html lang="en">

<!-- Start Head -->
<head>
<title>

Error

</title>
<script language="JavaS cript">
....

Here is the sample code:
#!/usr/bin/perl -w

use LWP::UserAgent;
use HTTP::Request;
use HTTP::Response;
use Crypt::SSLeay;

LWP::Debug::lev el('+');

$url = "https://squid.servebeer .com/getservices.do? user=Guest&pass word=JustLookin g&format=csv" ;
#$proxy="http://xxx.xxx.xxx.xxx :8080";

$ua = LWP::UserAgent->new();

if (defined $proxy)
{
$ENV{HTTPS_PROX Y} = $proxy;

# initialize from environment variables
$ua->env_proxy;
}

$req = HTTP::Request->new(GET => $url);
$response = $ua->request($req );
if ($response->is_error())
{
printf " %s\n", $response->status_line;
}

else
{
$content = $response->content();
print $content;
}

exit;
Jul 19 '05 #1
1 12662
Note: you'll reach more people at comp.lang.perl. misc. This newsgroup
does not officially exist, and so is not universally propogated.

LWP::UserAgent sends the wrong request for HTTPS connections by proxy.
In the docs for Crypt::SSLeay, you'll find this:
http://search.cpan.org/~chamas/Crypt...#PROXY_SUPPORT
LWP::UserAgent has its own methods of proxying which may work for you
and is likely incompatible with Crypt::SSLeay proxy support. To use
LWP::UserAgent proxy support, try something like:

my $ua = new LWP::UserAgent;
$ua->proxy([qw( https http )], "$proxy_ip:$pro xy_port");

At the time of this writing, libwww v5.6 seems to proxy https requests
fine with an Apache mod_proxy server. It sends a line like:

GET https://www.nodeworks.com HTTP/1.1

to the proxy server, which is not the CONNECT request that some
proxies would expect, so this may not work with other proxy servers
than mod_proxy. The CONNECT method is used by Crypt::SSLeay's internal
proxy support.
Crypt::SSLeay Proxy Support

For native Crypt::SSLeay proxy support of https requests, you need to
set an environment variable HTTPS_PROXY to your proxy server & port,
as in:

# PROXY SUPPORT
$ENV{HTTPS_PROX Y} = 'http://proxy_hostname_ or_ip:port';
$ENV{HTTPS_PROX Y} = '127.0.0.1:8080 ';

Use of the HTTPS_PROXY environment variable in this way is similar to
LWP::UserAgent->env_proxy() usage, but calling that method will likely
override or break the Crypt::SSLeay support, so do not mix the two.
</excerpt>

This is the code I use, *after* the UserAgent has been created:

# LWP proxying does not work for HTTPS
# This must cannot be set at the time $a is created
$ENV{HTTPS_PROX Y} = $proxy;
Jul 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1421
by: Robert | last post by:
using a proxy and https/SSL together I get the following SSL error : File "dscore.pyo", line 2257, in UrlOpenEx File "ClientCookie\_urllib2_support.pyo", line 572, in open File "ClientCookie\_urllib2_support.pyo", line 472, in http_response File "ClientCookie\_urllib2_support.pyo", line 589, in error File "urllib2.pyo", line 304, in _call_chain File "ClientCookie\_urllib2_support.pyo", line 181, in http_error_302 File...
1
2938
by: Lentdave67t | last post by:
Thank you in advance for any help you can provide. I am writing a C# program that checks to see if the URLs of favorites/bookmarks are still good. The problem I am having is that while the program is checking the URLs, the text in a label on the current window will not update until after all URLs are checked. I think the Form/Window is frozen while the http requests are occuring. Does anyone know of a way I can update the Form in real...
0
1173
by: Owen Jenkins | last post by:
My Access application downloads file from my website using the InetTransferLib http functions. One of my clients working from a hospital network gets an error message 'proxy authentication required' and cannot proceed. Can anyone point me in a direction to get around this problem? He is behind a firewall but has no trouble surfing using his web browser. Are there any settings he can adjust to make the download successful? Or do you think...
0
1157
by: Jimmy Carlsson | last post by:
Can I please get a reply on this or a hint on who or where I can ask. // Jimmy >-----Original Message----- >Hi! > >I'm automatically generating a proxy for a web service >using a supplied WSDL. The generator compiles the proxy
3
2351
by: Ohad Young | last post by:
Hi, I have a webservice method that returns an instance of a custom class I created (e.g., bank account). The class definition in the webservice contains properties, overrides Object.ToString method and etc. However, the proxy created for the webservice contains a definition for this class without the code I wrote. Instead it contains only public fields. I understand the reason, interoperability with none .net clients, but is there...
0
1259
by: Chad Z. Hower aka Kudzu | last post by:
I have a webservice which is running on SSL. All clients work fine - except one. The one user has a proxy. In the IE configuration he has a proxy filled in for HTTP, but not for HTTPS. Their proxy does not support HTTPS. When they enter the ?wsdl url into IE - all works fine and the WSDL is returned. But from our client app, it gives a a socket error. HOWEVER if the user goes into IE, and turns off the proxy setting, then the client works...
4
1849
by: c83 | last post by:
I am using Active Perl, and i-am having problems downloading files from internet because of the proxy. The script is workin when no proxy is present, but now it refuses to download files. Here is the script: #use module use XML::Simple; use Data::Dumper; use LWP::Simple; #test function sub test_func
1
1538
by: =?Utf-8?B?U3VzaGlTZWFu?= | last post by:
Hello, I have some code which use HttpWebRequest class and I see by default it use IE proxy settings. It means If I will not put any proxy this class get IE proxy and use it. How turn this off? Can I use some global settings in code force this class don't use IE by default?
4
4466
by: Jon | last post by:
I wrote a VS 2005 C# express programme that accesses a web service. It works fine when there's a direct connection to the internet, but on two different PCs with internet access via a proxy, I get this exception: System.Net.WebException: The request failed with HTTP status 407: Proxy Authentication Required. at System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream...
0
8927
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8764
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9428
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9289
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9210
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8159
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6026
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
3242
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2694
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.