Set a wrong Content-Length with LWP
"Octavian Rasnita" <[email protected]> Wed, 30 Jan 2019 16:11:30 +0200
| Newsgroups | gmane.comp.lang.perl.modules.lwp |
|---|---|
| Message-ID | <037001d4b8a5$b914cdd0$6500a8c0@OctavianTOSH> |
------=_NextPart_000_036D_01D4B8B6.76441900
Content-Type: text/plain;
charset="iso-8859-2"
Content-Transfer-Encoding: quoted-printable
Hi all,
Does anyone know if it is possible to set a wrong Content-Length with =
LWP?
Or if not, then how can we do it?
The following corrects it and sets it to "Content-length: 5":
$ua->post( $url, 'Content-Length' =3D> 3, Content =3D> '12345' );
The following also does the same, plus it shows a warning telling that =
Content-Length was corrected:
my $req =3D HTTP::Request->new( POST =3D> $url );
$req->header( 'Content-Length' =3D> 3 );
$req->content("12345");
I need to send a Content-Length that has a different value than the =
length of the posted content.
Thank you.
--Octavian
------=_NextPart_000_036D_01D4B8B6.76441900
Content-Type: text/html;
charset="iso-8859-2"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content=3D"text/html; charset=3Diso-8859-2" =
http-equiv=3DContent-Type>
<META name=3DGENERATOR content=3D"MSHTML 11.00.9600.19236">
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT size=3D2 face=3DArial>Hi all,</FONT></DIV>
<DIV><FONT size=3D2 face=3DArial></FONT> </DIV>
<DIV><FONT size=3D2 face=3DArial>Does anyone know if it is possible to =
set a wrong=20
Content-Length with LWP?</FONT></DIV>
<DIV><FONT size=3D2 face=3DArial>Or if not, then how can we do =
it?</FONT></DIV>
<DIV><FONT size=3D2 face=3DArial></FONT> </DIV>
<DIV><FONT size=3D2 face=3DArial>The following corrects it and sets it =
to=20
"Content-length: 5":</FONT></DIV>
<DIV><FONT size=3D2 face=3DArial>$ua->post( $url, 'Content-Length' =
=3D> 3,=20
Content =3D> '12345' );</FONT></DIV>
<DIV><FONT size=3D2 face=3DArial></FONT> </DIV>
<DIV><FONT size=3D2 face=3DArial>The following also does the same, plus =
it shows a=20
warning telling that Content-Length was corrected:</FONT></DIV>
<DIV><FONT size=3D2 face=3DArial>my $req =3D HTTP::Request->new( POST =
=3D> $url=20
);<BR>$req->header( 'Content-Length' =3D> 3=20
);<BR>$req->content("12345");<BR></FONT></DIV>
<DIV><FONT size=3D2 face=3DArial>I need to send a Content-Length that =
has a=20
different value than the length of the posted content.</FONT></DIV>
<DIV><FONT size=3D2 face=3DArial> </DIV></FONT>
<DIV><FONT size=3D2 face=3DArial>Thank you.</FONT></DIV>
<DIV><FONT size=3D2 face=3DArial></FONT> </DIV>
<DIV><FONT size=3D2 =
face=3DArial>--Octavian<BR></FONT></DIV></BODY></HTML>
------=_NextPart_000_036D_01D4B8B6.76441900--