Autor Beitrag
hui1991
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 433

Windows XP, WIndows Vista
Turbo Delphi Explorer| Delphi, PHP,Blitzbasic
BeitragVerfasst: Di 17.10.06 19:30 
Hallo,

ich hab ein problem mit meiner TIdHTTPServer-Komponente.
Aus irgendeinem grund bekomme ich immer ein Error.
Ich weis aber nicht warum :cry:
Ich hoffe ihr könnt mir helfen.
Ich schicke mal den Code.
ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
procedure TFOrm1.send(AThread: TIdPeerThread);
var
  items, test, filename, verzeichnissausgabe: string;
  maybe, size, maul, multi, filetyp, fauli, points: Integer;
  fs, fn: TFileStream;
  zeichen: char;
  fileyes: Boolean;
begin
  open := true;
  filename := AThread.Connection.ReadLn();
  ListBox1.Clear;
  Application.ProcessMessages;
  sList := TStringList.Create;
  try
    splitt(filename, ' ', sList);
    filename := sList.Strings[1];
  finally
    sList := TStringList.Create;
  end;
  filename[1] := '\';
  filename := trim(filename);
  points := 0;
  for maybe := length(filename) downto 0 do begin
    if ((filename[maybe] = '/'or (filename[maybe] = '\')) and (points = 0then begin
      fileyes := False;
      break;
    end;
    if ((filename[maybe] = '/'or (filename[maybe] = '\')) and (points > 0then begin
      fileyes := True;
      break;
    end;
    if (filename[maybe] = '.'then
      inc(points);
  end;
  if (filename[length(filename)] <> '\'and (not fileyes) then
    filename := filename + '\';
  Label2.Caption := filename;
  if (filename[length(filename)] = '/'or (filename[length(filename)] = '\'then begin
    filetyp := 0;
    open := false;
    verzeichnissausgabe := directory('files' + filename);
    savinglist := TStringList.Create;
    try
      savinglist.Text := verzeichnissausgabe;
      savinglist.SaveToFile('Temp.temp');
    finally
      savinglist.free;
    end;
    AThread.Start;
    AThread.COnnection.WriteLn('HTTP/1.1 200 OK');
    AThread.Connection.WriteLn('Server: hui1991s Fileserver');
    AThread.COnnection.WriteLn('Accept-Ranges: bytes');
    AThread.COnnection.WriteLn('Content-Length: ' + inttostr(GetFileSizeEx(ExtractFilePath(ParamStr(0)) + 'temp.temp')));
    AThread.COnnection.WriteLn('Connection: close');
    AThread.COnnection.WriteLn('Content-Type: text/html');
    AThread.COnnection.WriteLn('');
    fauli := AThread.Connection.WriteFile(ExtractFilePath(ParamStr(0)) + 'Temp.temp');
    AThread.Stop;
  end else begin
    filetyp := 1;
  end;
  if filetyp = 1 then begin
    Memo1.Clear;
    connectedf := True;
    sollichzaehln := False;
    items := '';
    size := GetFileSizeEx(ExtractFilePath(ParamStr(0)) + 'files' + filename);
    AThread.Start;
    AThread.COnnection.WriteLn('HTTP/1.1 200 OK');
    AThread.Connection.WriteLn('Server: hui1991s Fileserver');
    AThread.COnnection.WriteLn('Accept-Ranges: bytes');
    AThread.COnnection.WriteLn('Content-Length: ' + inttostr(size));
    AThread.COnnection.WriteLn('Connection: close');
    AThread.COnnection.WriteLn('');
    multi := AThread.Connection.WriteFile(ExtractFilePath(ParamStr(0)) + 'files' + filename);
    AThread.Stop;
    open := false;
  end;
end;


Hier ist noch die Datei Temp.temp:
ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<html>
 <head>
  <title>Index of files\</title>
 </head>
 <body>
<h1>Index of files\</h1>
<pre><img src="/icons/blank.gif" alt="Icon "> Name                    Last modified      Size  Description<hr><a href="/">Parent Directory</a></pre><br>
<pre><img src="/icons/folder.gif" alt="[DIR]"><a href="hallo">hallo</a>                  -    -   </pre>
<pre><img src="/icons/folder.gif" alt="[DIR]"><a href="icons">icons</a>                  -    -   </pre>
<pre><img src="/icons/folder.gif" alt="[DIR]"><a href="mist">mist</a>                  -    -   </pre>
<hr>
<address>Apache/2.2.2 (Win32) DAV/2 mod_ssl/2.2.2 OpenSSL/0.9.8b mod_autoindex_color PHP/5.1.4 Server at localhost Port 20000</address>
</body></html>


So macht mein PRogramm das. Aber aus einem Grund kommt da ein Error.
Kann mir da bitte jemand helfen?
Die Fehlermeldung als Bild ist unten im Anhang.
Ich hoffe mir kann dazu jemand helfen.
Weil ich will jetzt deswegen nicht mein PRogramm umstellen.
Gibt es eine Lösung dafür?
Ich möchte so den Server bis Montag fertig bekommen.

MfG
hui1991
Einloggen, um Attachments anzusehen!
Coder
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1383
Erhaltene Danke: 1

WinXP
D2005 PE
BeitragVerfasst: Di 17.10.06 21:51 
Weist du wie man Debugged?
www.dsdt.info/grundl...debugger.php?search=
Dann kannst du uns sagen bei welchem Befehl der Fehler kommt.
hui1991 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 433

Windows XP, WIndows Vista
Turbo Delphi Explorer| Delphi, PHP,Blitzbasic
BeitragVerfasst: Di 17.10.06 22:42 
Danke für deine Antwort,
Nach der Anleitung soll ich das hier sagen.
ICh weis das sollte man nicht so machen, aber zu dem PRoblem habe ich ein anderen Thema offen..
Jetzt will ich nur den Fehler finden.
Das PRoblem ist halt, das der Debugger mir den Fehler bei einem End aussprucht und nur die Fehlermeldung angezeigt wird, die oben als Screenabgebildet ist. Noch schwieriger ist es, das der Fehler nicht immer auftritt, ca. 4 bis 6 mal dann kommt der Fehler. Wenn ich es so starte, dann macht das Programm einfach net weiter. Ich sitzte an dem PRoblem schon 3 Stunden teilweise konnte ich es lösen, ich weis aber net warum.
Naja nun gut.
So rufe ich das send auf.
ICh mache die Stelle markiert wo die Meldung ausgegeben wird.

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
procedure TForm1.IdHTTPServer1Connect(AThread: TIdPeerThread);
begin
  if not open then begin
    open := True;
    send(AThread);
  end;
end;


Sonst sind eigentlich keine wichtigen Sachen drin. Außer, das hier köntne noch wichtig sein.
ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
function TForm1.directory(verzeichniss: string): string;
  //hier kommt der Teil, der den HTML Code für den Browser macht
  function SlashSep(const Path, S: string): string;
  begin
    if AnsiLastChar(Path)^ <> '\' then
      Result := Path + '\' + S else
      Result := Path + S;
  end;

var SearchRec: TSearchRec;
  ADirectory, schwaze: string;
  x: Integer;
begin
  ADirectory := verzeichniss;
  ListBox2.Clear;
  if FindFirst(SlashSep(ADirectory, '*.*'), faAnyFile, SearchRec) = 0 then begin
    try
      repeat
        if ((SearchRec.Name <> '.'and (SearchRec.Name <> '..')) then begin
          if (SearchRec.Attr = 32and (ADirectory = verzeichniss) then
            ListBox2.Items.Add('2|' + SearchRec.Name + '|' + inttostr(SearchRec.FindData.nFileSizeLow or (SearchRec.FindData.nFileSizeHigh shl 32)));
          if (SearchRec.Attr = 16and (ADirectory = verzeichniss) then
            ListBox2.Items.Add('1|' + SearchRec.Name + '|-');
        end;
      until FindNext(SearchRec) <> 0;
    finally
      SysUtils.FindClose(SearchRec);
    end;
  end;

  //hier wird der Code zusammengestellt
  sList2 := TStringList.Create;
  sList := TStringList.Create;
  try
    Memo1.Clear;
    sList2.Add('<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">');
    sList2.Add('<html>');
    sList2.Add(' <head>');
    sList2.Add('  <title>Index of ' + verzeichniss + '</title>');
    sList2.Add(' </head>');
    sList2.Add(' <body>');
    sList2.Add('<h1>Index of ' + verzeichniss + '</h1>');
    sList2.Add('<pre><img src="/icons/blank.gif" alt="Icon "> Name                    Last modified      Size  Description<hr><a href="/">Parent Directory</a></pre><br>');
    for x := 0 to ListBox2.Items.Count - 1 do begin
      splitt(ListBox2.Items.Strings[x], '|', sList);
      if sList.Strings[0] = '1' then
        schwaze := '<img src="/icons/folder.gif" alt="[DIR]">';
      if sList.Strings[0] = '2' then
        schwaze := '<img src="/icons/unknown.gif" alt="[   ]">';
      sList2.Add('<pre>' + schwaze + '<a href="' + sList.Strings[1] + '">' + sList.Strings[1] + '</a>                  -    ' + sList.Strings[2] + '   </pre>');
    end;
    sList2.Add('<hr>');
    sList2.Add('<address>Apache/2.2.2 (Win32) DAV/2 mod_ssl/2.2.2 OpenSSL/0.9.8b mod_autoindex_color PHP/5.1.4 Server at localhost Port ' + inttostr(IdHTTPServer1.DefaultPort) + '</address>');
    sList2.Add('</body></html>');
  //hier wird der Code zusammengestellt
    Result := sList2.Text;
  finally
    sList2.free;
    sList.free;
  end;
  //hier kommt der TEil, der den HTML code für den BRowser macht
end;


Wenn ich vom Obrigen Code auf Zeile 57 und 75 ganz am Anfang '//' setze also das es ein Kommentar ist, tritt der Fehler nicht auf, aber ich erreiche nicht das was ich will. ICh hab eigentlich meinen Ganzen COde jetzt gezeigt. Naja ich mach das nochmal zusammen:
ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
140:
141:
142:
143:
144:
145:
146:
147:
148:
149:
150:
151:
152:
153:
154:
155:
156:
157:
158:
159:
160:
161:
162:
163:
164:
165:
166:
167:
168:
169:
170:
171:
172:
173:
174:
175:
176:
177:
178:
179:
180:
181:
182:
183:
184:
185:
186:
187:
188:
189:
190:
191:
192:
193:
194:
195:
196:
197:
198:
199:
200:
201:
202:
203:
204:
205:
206:
207:
208:
209:
210:
211:
212:
213:
214:
215:
216:
217:
218:
219:
220:
221:
222:
223:
224:
225:
226:
227:
228:
229:
230:
231:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, IdBaseComponent, IdComponent, IdTCPServer, IdCustomHTTPServer,
  IdHTTPServer, StdCtrls, ExtCtrls;

type
  TForm1 = class(TForm)
    Memo1: TMemo;
    IdHTTPServer1: TIdHTTPServer;
    Label1: TLabel;
    Timer1: TTimer;
    ListBox1: TListBox;
    Label2: TLabel;
    ListBox2: TListBox;
    procedure IdHTTPServer1Connect(AThread: TIdPeerThread);
    procedure send(AThread: TIdPeerThread);
    procedure splitt(zeichenkette: string; leerzeichen: char; sList: TStringList);
    function directory(verzeichniss: string): string;
    function GetFileSizeEx(const AFileName: string): Int64;
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;
  Intzaehler, msekunden: Integer;
  sollichzaehln, connectedf, open: boolean;
  sList, savinglist, sList2: TStringlist;
implementation

{$R *.dfm}

procedure TForm1.IdHTTPServer1Connect(AThread: TIdPeerThread);
begin
  if not open then begin
    open := True;
    send(AThread);
  end;
end;

procedure TFOrm1.send(AThread: TIdPeerThread);
var
  items, test, filename, verzeichnissausgabe: string;
  maybe, size, maul, multi, filetyp, fauli, points: Integer;
  fs, fn: TFileStream;
  zeichen: char;
  fileyes: Boolean;
begin
  open := true;
  filename := AThread.Connection.ReadLn();
  ListBox1.Clear;
  Application.ProcessMessages;
  sList := TStringList.Create;
  try
    splitt(filename, ' ', sList);
    filename := sList.Strings[1];
  finally
    sList := TStringList.Create;
  end;
  filename[1] := '\';
  filename := trim(filename);
  points := 0;
  for maybe := length(filename) downto 0 do begin
    if ((filename[maybe] = '/'or (filename[maybe] = '\')) and (points = 0then begin
      fileyes := False;
      break;
    end;
    if ((filename[maybe] = '/'or (filename[maybe] = '\')) and (points > 0then begin
      fileyes := True;
      break;
    end;
    if (filename[maybe] = '.'then
      inc(points);
  end;
  if (filename[length(filename)] <> '\'and (not fileyes) then
    filename := filename + '\';
  Label2.Caption := filename;
  if (filename[length(filename)] = '/'or (filename[length(filename)] = '\'then begin
    filetyp := 0;
    open := false;
    verzeichnissausgabe := directory('files' + filename);
    savinglist := TStringList.Create;
    try
      savinglist.Text := verzeichnissausgabe;
      savinglist.SaveToFile('Temp.temp');
    finally
      savinglist.free;
    end;
    AThread.Start;
    AThread.COnnection.WriteLn('HTTP/1.1 200 OK');
    AThread.Connection.WriteLn('Server: hui1991s Fileserver');
    AThread.COnnection.WriteLn('Accept-Ranges: bytes');
    AThread.COnnection.WriteLn('Content-Length: ' + inttostr(GetFileSizeEx(ExtractFilePath(ParamStr(0)) + 'temp.temp')));
    AThread.COnnection.WriteLn('Connection: close');
    AThread.COnnection.WriteLn('Content-Type: text/html');
    AThread.COnnection.WriteLn('');
    fauli := AThread.Connection.WriteFile(ExtractFilePath(ParamStr(0)) + 'Temp.temp');
    AThread.Stop;
  end else begin
    filetyp := 1;
  end;
  if filetyp = 1 then begin
    Memo1.Clear;
    connectedf := True;
    sollichzaehln := False;
    items := '';
    size := GetFileSizeEx(ExtractFilePath(ParamStr(0)) + 'files' + filename);
    AThread.Start;
    AThread.COnnection.WriteLn('HTTP/1.1 200 OK');
    AThread.Connection.WriteLn('Server: hui1991s Fileserver');
    AThread.COnnection.WriteLn('Accept-Ranges: bytes');
    AThread.COnnection.WriteLn('Content-Length: ' + inttostr(size));
    AThread.COnnection.WriteLn('Connection: close');
    AThread.COnnection.WriteLn('');
    multi := AThread.Connection.WriteFile(ExtractFilePath(ParamStr(0)) + 'files' + filename);
    AThread.Stop;
    open := false;
  end;
end;

procedure TForm1.splitt(zeichenkette: string; leerzeichen: char; sList: TStringList);
var s, r: string;
  i, x, j, k: integer;
  arr: array[0..200of string;
begin
  s := zeichenkette;
  i := 0;
  sList.Clear;
  repeat
    j := Pos(leerzeichen, s);
    if j > 0 then begin
      r := copy(s, 1, j - 1);
      arr[i] := r;
      inc(i);
      delete(s, 1, j);

    end
    else break;
  until j = 0;
  if length(s) > 0 then begin
    arr[i] := s;
    for k := 0 to i do
      slIst.Add(arr[k]);
  end
end;

function TForm1.directory(verzeichniss: string): string;
  //hier kommt der Teil, der den HTML Code für den Browser macht
  function SlashSep(const Path, S: string): string;
  begin
    if AnsiLastChar(Path)^ <> '\' then
      Result := Path + '\' + S else
      Result := Path + S;
  end;

var SearchRec: TSearchRec;
  ADirectory, schwaze: string;
  x: Integer;
begin
  ADirectory := verzeichniss;
  ListBox2.Clear;
  if FindFirst(SlashSep(ADirectory, '*.*'), faAnyFile, SearchRec) = 0 then begin
    try
      repeat
        if ((SearchRec.Name <> '.'and (SearchRec.Name <> '..')) then begin
          if (SearchRec.Attr = 32and (ADirectory = verzeichniss) then
            ListBox2.Items.Add('2|' + SearchRec.Name + '|' + inttostr(SearchRec.FindData.nFileSizeLow or (SearchRec.FindData.nFileSizeHigh shl 32)));
          if (SearchRec.Attr = 16and (ADirectory = verzeichniss) then
            ListBox2.Items.Add('1|' + SearchRec.Name + '|-');
        end;
      until FindNext(SearchRec) <> 0;
    finally
      SysUtils.FindClose(SearchRec);
    end;
  end;

  //hier wird der Code zusammengestellt
  sList2 := TStringList.Create;
  sList := TStringList.Create;
  try
    Memo1.Clear;
    sList2.Add('<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">');
    sList2.Add('<html>');
    sList2.Add(' <head>');
    sList2.Add('  <title>Index of ' + verzeichniss + '</title>');
    sList2.Add(' </head>');
    sList2.Add(' <body>');
    sList2.Add('<h1>Index of ' + verzeichniss + '</h1>');
    sList2.Add('<pre><img src="/icons/blank.gif" alt="Icon "> Name                    Last modified      Size  Description<hr><a href="/">Parent Directory</a></pre><br>');
    for x := 0 to ListBox2.Items.Count - 1 do begin
      splitt(ListBox2.Items.Strings[x], '|', sList);
      if sList.Strings[0] = '1' then
        schwaze := '<img src="/icons/folder.gif" alt="[DIR]">';
      if sList.Strings[0] = '2' then
        schwaze := '<img src="/icons/unknown.gif" alt="[   ]">';
      sList2.Add('<pre>' + schwaze + '<a href="' + sList.Strings[1] + '">' + sList.Strings[1] + '</a>                  -    ' + sList.Strings[2] + '   </pre>');
    end;
    sList2.Add('<hr>');
    sList2.Add('<address>Apache/2.2.2 (Win32) DAV/2 mod_ssl/2.2.2 OpenSSL/0.9.8b mod_autoindex_color PHP/5.1.4 Server at localhost Port ' + inttostr(IdHTTPServer1.DefaultPort) + '</address>');
    sList2.Add('</body></html>');
  //hier wird der Code zusammengestellt
    Result := sList2.Text;
  finally
    sList2.free;
    sList.free;
  end;
  //hier kommt der TEil, der den HTML code für den BRowser macht
end;

function TForm1.GetFileSizeEx(const AFileName: string): Int64;
var
  F: TSearchRec;
begin
  Result := -1;
  if FindFirst(AFileName, faAnyFile, F) = 0 then
  begin
    try
      Result := F.FindData.nFileSizeLow or (F.FindData.nFileSizeHigh shl 32);
    finally
      SysUtils.FindClose(F);
    end;
  end;
end;

end.


ICh hoffe ich habe jetzt alle Informationen euch mitgeteilt, damit ihr mir Helfen könnte, das Problem aus der Welt zu schaffen ^^

MfG
hui1991
alias5000
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 2145

WinXP Prof SP2, Ubuntu 9.04
C/C++(Code::Blocks, VS.NET),A51(Keil),Object Pascal(D2005PE, Turbo Delphi Explorer) C# (VS 2008 Express)
BeitragVerfasst: Di 17.10.06 22:51 
Ich würde dann mal in der Prozedur Send weiterdebuggen. Einfach n Breakpoint drauf legen, mit F7 reinhüpfen und dann mit F8 einzeln die Befehle abgehen. Auf diese Weise kommst du dem Problem evtl. näher.

_________________
Programmers never die, they just GOSUB without RETURN
hui1991 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 433

Windows XP, WIndows Vista
Turbo Delphi Explorer| Delphi, PHP,Blitzbasic
BeitragVerfasst: Mi 18.10.06 06:54 
Könnte es vielleicht daran liegen, das bei procedure TForm1.IdHTTPServer1Connect(AThread: TIdPeerThread);
Wenn man es Startet vorne Kein Punkt bei Begin und dem Vorletzten End?
ICh hab mal ein Screen unten eingefügt. So weit ich weis, geht der Debugger nur dort hin wo ein Punkt vorne ist...

Beim Debuggen kam ich auf diese Andere Meldung die auch im Anhang drin ist.
ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
procedure TFOrm1.send(AThread: TIdPeerThread);
var
  items, test, filename, verzeichnissausgabe: string;
  maybe, size, maul, multi, filetyp, fauli, points: Integer;
  fs, fn: TFileStream;
  zeichen: char;
  fileyes: Boolean;
begin
  open := true;
  filename := AThread.Connection.ReadLn();
  ListBox1.Clear;
  Application.ProcessMessages;
  sList := TStringList.Create;
  try
    splitt(filename, ' ', sList);
    filename := sList.Strings[1];
  finally
    sList := TStringList.Create;
  end;
  filename[1] := '\';
  filename := trim(filename);
  points := 0;
  for maybe := length(filename) downto 0 do begin
    if ((filename[maybe] = '/'or (filename[maybe] = '\')) and (points = 0then begin
      fileyes := False;
      break;
    end;
    if ((filename[maybe] = '/'or (filename[maybe] = '\')) and (points > 0then begin
      fileyes := True;
      break;
    end;
    if (filename[maybe] = '.'then
      inc(points);
  end;
  if (filename[length(filename)] <> '\'and (not fileyes) then
    filename := filename + '\';
  Label2.Caption := filename;
  if (filename[length(filename)] = '/'or (filename[length(filename)] = '\'then begin  //zu dem Zeitpunkt ist filename ein Undefinierter Ausdruck.
    filetyp := 0;
    open := false;
    verzeichnissausgabe := directory('files' + filename);
    savinglist := TStringList.Create;
    try
      savinglist.Text := verzeichnissausgabe;
      savinglist.SaveToFile('Temp.temp');
    finally
      savinglist.free;
    end;
    AThread.Start;
    AThread.COnnection.WriteLn('HTTP/1.1 200 OK');
    AThread.Connection.WriteLn('Server: hui1991s Fileserver');
    AThread.COnnection.WriteLn('Accept-Ranges: bytes');
    AThread.COnnection.WriteLn('Content-Length: ' + inttostr(GetFileSizeEx(ExtractFilePath(ParamStr(0)) + 'temp.temp')));
    AThread.COnnection.WriteLn('Connection: close');
    AThread.COnnection.WriteLn('Content-Type: text/html');
    AThread.COnnection.WriteLn('');
    fauli := AThread.Connection.WriteFile(ExtractFilePath(ParamStr(0)) + 'Temp.temp');
    AThread.Stop;
  end else begin
    filetyp := 1;
  end;
  if filetyp = 1 then begin
    Memo1.Clear;
    connectedf := True;
    sollichzaehln := False;
    items := '';
    size := GetFileSizeEx(ExtractFilePath(ParamStr(0)) + 'files' + filename);
    AThread.Start;
    AThread.COnnection.WriteLn('HTTP/1.1 200 OK');
    AThread.Connection.WriteLn('Server: hui1991s Fileserver');
    AThread.COnnection.WriteLn('Accept-Ranges: bytes');
    AThread.COnnection.WriteLn('Content-Length: ' + inttostr(size));
    AThread.COnnection.WriteLn('Connection: close');
    AThread.COnnection.WriteLn('');
    multi := AThread.Connection.WriteFile(ExtractFilePath(ParamStr(0)) + 'files' + filename);
    AThread.Stop;
    open := false;
  end;
end;


Okay ich hab wieder geschlossen (Strg+F2) und wieder gestartet, danach hab ich meine Seite 127.0.0.1:20000/ geöffnet, Debugger durchlaufen lassen und etz ist mein Delphi mir weggelaufen (Es hat sich einfachso geschlossen) :(


Ich hab es wieder geöfnet, die COnnect PRocedure gelöscht und wieder neu gemacht, der Fehler mit dem Begin, End besteht weiter. Also ich weis net warum delphi mich mag. Der COde sollte funktionieren.
Wenn ich bei Zeile 57 und 75 im Obigen Code mit // davor setze zum Kommentieren, dann ist zwar kein Fehler mehr soweit da, aber das PRoblem mit dem Begin und End ist weiter... ICh weis einfach nicht warum das schon wieder kommt...

Wenn ich die zeile 75 wieder von // entferne, dann kommt die FEhlermeldung nicht, es wird auch das jpg geladen.
Dies machte ich mit zeile 57 und aufeinmal kam die Meldung Robots.txt nicht gefunden???
So eine Datei wollte ich nie öffnen...
ich hab den code immer um 4 zeichen verädert. Mal das Kommentar weg mal net..
Und immer andere Fehlermeldungen.

Im Anhang Reset by peer, ist dann der Screen der Fehlermeldung wenn ich die letzte Meldung ignoriere und die 127.0.0.1:20000/ öffne. Die Website wurde geladen, der Fehler könnte aber PRobleme für später machen...
Der Fehler tritt in Zeile 76 Auf.

Also ich muss etz schluss machen ich hoffe ich habe jetzt mein Vorgehen gut erklärt, was ich aufjedenfall net so verstehe, wenn ich nur Kommentierungen ändere...

MfG
hui1991

Edit:// Anhang korriegiert
Einloggen, um Attachments anzusehen!