Bear with me? I suspect the question will be easy for someone... but 
I have to set a scene:

I have written an HTTP client app, using ICS. The heart of my program 
was created from the ICS demo "HttpTst".

The program fetchs some XML from a little box you can plug into a LAN 
or the internet. The XML tells the client about temperatures or 
humidities sensors on the box can "see".

The Big Puzzle: If I point my client at a server on my LAN, the XML 
is collected as expected. However, even after I turn my firewall off 
(which was part of the problem!), if I point it at...

http://80.250.3.197/temper.xml

... which is the right page in another of the boxes, my client 
says...

Not using proxy
cmd> POST /temper.xml HTTP/1.0
cmd> Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*
cmd> Connection: Keep-Alive
cmd> Content-Type: text/plain
cmd> User-Agent: Mozilla/4.0 (compatible; ICS)
cmd> Host: 80.250.3.197
cmd> Content-Length: 0
cmd> 
RequestDone, no error. Status =0
StatusCode = 0 (No route to host (Error #10065))

If I point my browser at the same URL, using the same pc, I get a 
sensible response. The command summary is similar to the above, but 
after the "Content-Length: 0" and "cmd>", I get....

text/html=> temper.xml
Location=http://192.168.0.26/temper.xml
URL = http://192.168.0.26/temper.xml
Document = temper.xml
RequestDone, no error. Status =200
StatusCode=200(OK)

When I adapted (plndered?) the ICS demo HttpTst to provide the heart 
for my program, I "trimmed it down" to focus just on the things I 
needed, understood.

MAYBE SOME KIND READER CAN SEE WHERE I "CUT" TOO MUCH? >>>>>>

I suspect my error lies somewhere in my preparation for the 
request.... Most of what was in HttpTst is still present below, but 
bits have been remmed out... anyone see a bit that's needed for 
across-the-internet, but not critcal in across-LAN?...


begin
    Request:=httpPOST;
    DisplayMemo.Clear;
    DocumentMemo.Clear;

    try
        DataOut := TMemoryStream.Create;
        Buf     := '';//DataEdit.Text;
        if Length(Buf) > 0 then      { Check if some data to post }
            DataOut.Write(Buf[1], Length(Buf));
        DataOut.Seek(0, soFromBeginning);

        //if NoBasicAuthCheckBox.Checked then
          //  HttpCli1.Options      := HttpCli1.Options + 
[httpoNoBasicAuth]
        //else
            HttpCli1.Options      := HttpCli1.Options - 
[httpoNoBasicAuth];
        {if NoNTLMAuthCheckBox.Checked then
            HttpCli1.Options      := HttpCli1.Options + 
[httpoNoNTLMAuth]
        else }
            HttpCli1.Options      := HttpCli1.Options - 
[httpoNoNTLMAuth];
        HttpCli1.FollowRelocation := true;//not 
NoRelocCheckbox.Checked;
        HttpCli1.SendStream       := DataOut;
        HttpCli1.Proxy            := '';// ProxyHostEdit.Text;
        HttpCli1.ProxyPort        := IPPort.Text;
        HttpCli1.Connection       := 'Keep-Alive';
        HttpCli1.RcvdStream       := nil;
        HttpCli1.ContentTypePost  := 
'text/plain';//PostContentTypeEdit.Text;
        HttpCli1.Cookie           := '';//CookieEdit.Text;
        HttpCli1.URL              := 
'http://'+IPAddress.text+'/temper.xml';//URLEdit.Text;
        HttpCli1.RequestVer       := '1.0';//'1.' +
                                   //  
IntToStr(HttpVersionComboBox.ItemIndex);

        if HttpCli1.Proxy <> '' then
            Display('Using proxy ''' + HttpCli1.Proxy + ':' +
                                  HttpCli1.ProxyPort + '''')
        else
            Display('Not using proxy');

        try
            if Request = httpPOST then
                HttpCli1.Post
            else
                HttpCli1.Put;
        except
            DataOut.Free;
            Display('POST Failed !');
            Display('StatusCode   = ' + 
IntToStr(HttpCli1.StatusCode));
            Display('ReasonPhrase = ' + HttpCli1.ReasonPhrase);
            Exit;
        end;
        DataOut.Free;

        Display('StatusCode = ' + IntToStr(HttpCli1.StatusCode) +
                ' (' + HttpCli1.ReasonPhrase + ')');

        {if DisplayHeaderCheckBox.Checked then
            for I := 0 to HttpCli1.RcvdHeader.Count - 1 do
                Display('hdr>' + HttpCli1.RcvdHeader.Strings[I]);
         }
        if HttpCli1.ContentLength = 0 then
            DocumentMemo.Lines.Add('No document received.')
        else begin
            DataIn := TFileStream.Create(HttpCli1.DocName, 
fmOpenRead);
            try
                if Copy(HttpCli1.ContentType, 1, 5) = 'text/' then
                    DocumentMemo.Lines.LoadFromStream(DataIn)
                else begin
                    DocumentMemo.Lines.Add('Content type is ' +
                                           HttpCli1.ContentType);
                    DocumentMemo.Lines.Add('Document stored in ''' +
                                           DocFileName +
                                           ''' Size=' + 
IntToStr(DataIn.Size));
                end;
            finally
                DataIn.Free;
            end;
        end;
    finally
       // SetButtonState(TRUE);
    end;
MemoShowHide(not boHideDoc);  //writing to memo undoes "hide"

=================

(By now, across LAN, and after various HttpCli1 event handlers have 
done their stuff, my "Document" memo is filled with the XML served by 
the URL I point the above to.)

Thanks for your time looking at this.

========
Has anyone done a Delphi-helpfile-like guide (or similar!!) to the 
meaning, effect, etc, of the various THttpCli properties? I know... 
it's one of those "if you have to ask, you won't understand the 
answer" type deals. I did figure out that I should fill HttpCli1.URL 
with the URL of the resourse I wanted to talk to, but many of the 
other properties are a bit of a mystery to me. Maybe if I could read 
more about them, I'd see why my client can talk to a server on a LAN, 
but not across the net.

Ah well... sorry for the long post from anew member.

Tom Boyd

(If you're interested in the "box" that serves sensor results to a 
LAN, see....

http://sheepdogsoftware.co.uk/sc2we.htm

... or, for full sourcecode of my  data logging program... it DOES 
work across LAN!...

http://sheepdogguides.com/dt5g.htm

http://sheepdogsoftware.co.uk
Freeware, shareware. Kids, parents, schools... and others.



        
        
                
___________________________________________________________ 
Yahoo! Messenger - NEW crystal clear PC to PC calling worldwide with voicemail 
http://uk.messenger.yahoo.com


-- 
To unsubscribe or change your settings for TWSocket mailing list
please goto http://www.elists.org/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be

Reply via email to