It's simple code but I got 400 URL must be absolute and it says it's a Internal response

S

sisapinusa

Hello,
I'm perl beginner.
It's quite simple question.

I'm testing below code:

$req = HTTP::Request->new(GET => '/performers/ HTTP/1.1');
$req->header(Host => 'kihong.dev003.ent');
$res = $ua->simple_request($req);

but only I got this:

400 (Bad Request) URL must be absolute
Content-Type: text/plain
Client-Date: Wed, 07 Dec 2005 22:33:22 GMT
Client-Warning: Internal response

400 URL must be absolute

It says it's "internal response", that means it's from perl module
itself.

As you can see in my code, I need to send this HTTP header

GET /performers/ HTTP/1.1
Host: kihong.dev003.ent

So I coded in C language same thing for test, then of course it works
fine.
What's wrong with me? Isn't it simple header?

Please help me out, it's my first step, but I got stuck ;;

Thank you.
 
S

Sherm Pendley

I'm testing below code:

$req = HTTP::Request->new(GET => '/performers/ HTTP/1.1');
$req->header(Host => 'kihong.dev003.ent');

That's *not* how the docs say to do that. The example given in the HTTP::
Request docs is this:

$request = HTTP::Request->new(GET => 'http://www.example.com/');

Don't micro-manage the process. HTTP::Request knows what version of HTTP it
wants to use, and how to split the URL up so that the path and hostname will
appear where they're supposed to.

sherm--
 
S

sisapinusa

Thank you guys very much.
But there is one more strange.

I tried below line, and it works find.
$req = HTTP::Request->new(GET => 'http://kihong.dev003.ent/performers
HTTP/1.1');

I got HTTP below header as I expected
HTTP/1.1 302 Moved Temporarily
Server: Zeus/4.3
Date: Wed, 07 Dec 2005 21:53:18 GMT
Set-Cookie: SC=okay; domain=kihong.dev003.ent
Content-Length: 212
Location: /performers/?SC=C
Content-type: text/plain
Content-Type: text/html

<html><head><title>Error 302 Moved Temporarily
</title></head><body bgcolor=#ffffff><h2>Error 302 Moved Temporarily
</h2><p><i>Powered by <a href="http://errors.zeus.com/">Zeus
Technology</a></i></body></html>

But if I try below line, it doesn't work.
$req = HTTP::Request->new(GET =>
'http://kihong.dev003.ent/performers');

I got below HTTP.
HTTP/1.1 301 Moved Permanently
Date: Thu, 08 Dec 2005 15:22:22 GMT
Location: http://kihong.dev003.ent/performers/
Server: Zeus/4.3
Content-Length: 212
Content-Type: text/html
Client-Date: Thu, 08 Dec 2005 15:22:30 GMT
Client-Peer: 10.4.12.5:80
Client-Response-Num: 1
Title: Error 301 Moved Permanently

<html><head><title>Error 301 Moved Permanently
</title></head><body bgcolor=#ffffff><h2>Error 301 Moved Permanently
</h2><p><i>Powered by <a href="http://errors.zeus.com/">Zeus
Technology</a></i></body></html>

Only the different is, HTTP/1.1 string. I took me some time to find
out.
But I want to know why. Is it Zeus server problem? or..

If you guys have any idea, pleaaase let me know..
Please...

Thanks you
 
A

A. Sinan Unur

(e-mail address removed) wrote in @z14g2000cwz.googlegroups.com:
Thank you guys very much.
But there is one more strange.

I tried below line, and it works find.
$req = HTTP::Request->new(GET => 'http://kihong.dev003.ent/performers
HTTP/1.1');

You must think that you can just keep on making stuff up until it works.

Note that the string " HTTP/1.1" in your request does *not* specify the
protocol to use.
I got HTTP below header as I expected
HTTP/1.1 302 Moved Temporarily
Server: Zeus/4.3
Date: Wed, 07 Dec 2005 21:53:18 GMT
Set-Cookie: SC=okay; domain=kihong.dev003.ent
Content-Length: 212
Location: /performers/?SC=C

It appears that the correct URL is

http://kihong.dev003.ent/performers/

The trailing slash matters.
But I want to know why. Is it Zeus server problem? or..

Since you haven't told us the correct URL, we cannot observe how the
server behaves.

In the absence of any concrete information, it is a safe bet to assume
that you are doing something wrong.
If you guys have any idea, pleaaase let me know..
Please...

Whining and pleas rarely elicit sympathy, but mainly serve to annoy
people.

Sinan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,176
Messages
2,570,950
Members
47,503
Latest member
supremedee

Latest Threads

Top