[mod_python] Simple Issue, Baffling

Waitman Gobble waitman at waitman.net
Thu Jan 26 16:34:28 EST 2006


Did you try making a "head" or "get" request and watch the headers. I
agree it seems that the thing is returning content-type text/plain.

Since you are on a winders machine, you might not have an easy way to do
a HEAD request. But maybe you do.

JUST IN CASE, you can use telnet like this:

I normally use the HEAD command on a *nix machine. If you don't have
access to such a thing, you can do it from the command prompt on your
windows machine.

Start -> Run
type in "cmd" and press "OK"
a black console window (*should*) appear.

you should see something like this:

Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

C:\Documents and Settings\YOU-USER>

at the prompt, type in the following:

telnet example.com 80

The screen may go blank, with a cursor at the top. you may have to type
in the dark, without getting an echo. I think on older versions it
didn't use to do this, but my memory may be froggy.

type in the following:

HEAD http://example.com/doesnotexist HTTP/1.0

and press <Enter> twice.

The response should appear.

HTTP/1.1 200 OK
Connection: close
Date: Fri, 20 Jan 2006 18:30:48 GMT
Server: Microsoft-IIS/6.0
X-Powered-By: ASP.NET
X-AspNet-Version: 1.1.4322
Cache-Control: private
Content-Type: text/html; charset=utf-8



Connection to host lost.




or i did a little checker for another group last week.

here is a little HEAD and GET checker. 5 minute version,
source below.

That way you don't have to do the goofy telnet stuff. :-)


(in bcb 6.0 with indy)

http://www.nodemap.com/more/gethead.exe

# md5sum gethead.exe
dc05e2e3c9f73f801f5da92dd9a47885  gethead.exe


//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop

#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
        : TForm(Owner)
{
Memo1->Lines->Clear();

}
//---------------------------------------------------------------------------

void __fastcall TForm1::Button1Click(TObject *Sender)
{

        Memo1->Lines->Add("");
        if (CheckBox1->Checked) {
                Memo1->Lines->Add("Attention: Following Redirects");
                IdHTTP1->HandleRedirects=true;
        } else {
                Memo1->Lines->Add("Attention: Not Following
Redirects");
                IdHTTP1->HandleRedirects=false;
        }

        Memo1->Lines->Add("HEAD "+Edit1->Text+" on port "+Edit2->Text);
        IdHTTP1->Port=Edit2->Text.ToInt();
        try {
                IdHTTP1->Head(Edit1->Text);
        }
        catch (...)
        {
                //
        }
        Memo1->Lines->Add(IdHTTP1->Response->ResponseText);
        Memo1->Lines->Add(IdHTTP1->Response->RawHeaders->Text);

}
//---------------------------------------------------------------------------

void __fastcall TForm1::Button2Click(TObject *Sender)
{
        Memo1->Lines->Add("");
        if (CheckBox1->Checked) {
                Memo1->Lines->Add("Attention: Following Redirects");
                IdHTTP1->HandleRedirects=true;
        } else {
                Memo1->Lines->Add("Attention: Not Following
Redirects");
                IdHTTP1->HandleRedirects=false;
        }

        Memo1->Lines->Add("GET "+Edit1->Text+" on port "+Edit2->Text);
        IdHTTP1->Port=Edit2->Text.ToInt();
        try {
                IdHTTP1->Get(Edit1->Text);
        }
        catch (...)
        {
                //
        }
        Memo1->Lines->Add(IdHTTP1->Response->ResponseText);
        Memo1->Lines->Add(IdHTTP1->Response->RawHeaders->Text);

}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button3Click(TObject *Sender)
{
Memo1->Lines->Clear();
}
//---------------------------------------------------------------------------


Header file

//---------------------------------------------------------------------------

#ifndef Unit1H
#define Unit1H
//---------------------------------------------------------------------------
#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
#include <IdBaseComponent.hpp>
#include <IdComponent.hpp>
#include <IdHTTP.hpp>
#include <IdTCPClient.hpp>
#include <IdTCPConnection.hpp>
//---------------------------------------------------------------------------
class TForm1 : public TForm
{
__published:	// IDE-managed Components
        TMemo *Memo1;
        TEdit *Edit1;
        TButton *Button1;
        TButton *Button2;
        TIdHTTP *IdHTTP1;
        TEdit *Edit2;
        TLabel *Label1;
        TLabel *Label2;
        TCheckBox *CheckBox1;
        TButton *Button3;
        TLabel *Label3;
        TLabel *Label4;
        void __fastcall Button1Click(TObject *Sender);
        void __fastcall Button2Click(TObject *Sender);
        void __fastcall Button3Click(TObject *Sender);
private:	// User declarations
public:		// User declarations
        __fastcall TForm1(TComponent* Owner);
};
//---------------------------------------------------------------------------
extern PACKAGE TForm1 *Form1;
//---------------------------------------------------------------------------
#endif


Waitman


David Worley wrote:
> Yeah, typo. Thanks for pointing that out.



More information about the Mod_python mailing list