Changeset 100 for trunk/Packages


Ignore:
Timestamp:
Oct 2, 2012, 2:52:20 PM (12 years ago)
Author:
chronos
Message:
  • Upraveno: V balíčku CoolWeb některé seznamy změněny z typu TStringList na TListString.
Location:
trunk/Packages
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Packages/CoolWeb/Modules/UUser.pas

    r98 r100  
    6161  try
    6262    DbRows := TDbRows.Create;
     63    if HandlerData.Request.Cookies.SearchKey('SessionId') <> -1 then begin
    6364    Database.Query(DbRows, 'SELECT * FROM `UserOnline` WHERE `SessionId`="' +
    6465      HandlerData.Request.Cookies.Values['SessionId'] + '"');
     
    7576      User := 1;
    7677    end;
     78
     79    end;
    7780  finally
    7881    DbRows.Free;
  • trunk/Packages/CoolWeb/WebServer/UHTTPServer.pas

    r96 r100  
    1313  EEmptyHTTPHandler = class(Exception);
    1414
    15   TQueryParameterList = class(TStringList)
     15  TQueryParameterList = class(TDictionaryStringString)
    1616    procedure Parse(Text: string);
    1717    function Syntetize: string;
     
    2020  { TCookieList }
    2121
    22   TCookieList = class(TStringList)
     22  TCookieList = class(TDictionaryStringString)
    2323    procedure Parse(Text: string);
    2424    function Syntetize: string;
     
    148148    WriteString('<h5>Request HTTP headers</h5>');
    149149    for I := 0 to Request.Headers.Count - 1 do begin;
    150       WriteString(Request.Headers.Items[I].Value + '<br/>');
     150      with Request.Headers.Items[I] do
     151        WriteString(Key + ': ' + Value + '<br/>');
     152    end;
     153
     154    WriteString('<h5>Request HTTP GET</h5>');
     155    for I := 0 to Request.Query.Count - 1 do begin
     156      with Request.Query.Items[I] do
     157      WriteString(Key + ': ' + Value + '<br/>');
    151158    end;
    152159
    153160    WriteString('<h5>Request HTTP cookies</h5>');
    154     for I := 0 to Request.Cookies.Count - 1 do begin;
    155       WriteString(Request.Cookies.Strings[I] + '<br/>');
     161    for I := 0 to Request.Cookies.Count - 1 do begin
     162      with Request.Cookies.Items[I] do
     163      WriteString(Key + ': ' + Value + '<br/>');
    156164    end;
    157165
    158166    //WriteString('Session id: ' + SessionId);
    159167    WriteString('<h5>Session variables</h5>');
    160     for I := 0 to Session.Count - 1 do begin;
    161       WriteString(Session.Strings[I] + '<br/>');
     168    for I := 0 to Session.Count - 1 do begin
     169      with Session do
     170      WriteString(Names[I] + ': ' + ValueFromIndex[I] + '<br/>');
    162171    end;
    163172
    164173    WriteString('<h5>Request HTTP POST</h5>');
    165     for I := 0 to Request.Post.Count - 1 do begin;
    166       WriteString(Request.Post.Strings[I] + '<br/>');
     174    for I := 0 to Request.Post.Count - 1 do begin
     175      with Request.Post.Items[I] do
     176      WriteString(Key + ': ' + Value + '<br/>');
    167177    end;
    168178
     
    173183    WriteString('<h5>Response HTTP headers</h5>');
    174184    with Response.Content do
    175     for I := 0 to Response.Headers.Count - 1 do begin;
    176       WriteString(Response.Headers.Items[I].Value + '<br/>');
     185    for I := 0 to Response.Headers.Count - 1 do begin
     186      with Response.Headers.Items[I] do
     187      WriteString(Key + ': ' + Value + '<br/>');
    177188    end;
    178189
    179190    WriteString('<h5>Response HTTP cookies</h5>');
    180191    for I := 0 to Response.Cookies.Count - 1 do begin;
    181       WriteString(Response.Cookies.Strings[I] + '<br/>');
     192      with Response.Cookies.Items[I] do
     193      WriteString(Key + ': ' + Value + '<br/>');
    182194    end;
    183195  end;
     
    352364      Pair.Explode(Parts[I], '=', StrToStr);
    353365      if Pair.Count >= 2 then
    354         Values[Pair[0]] := Pair[1];
     366        Add(Pair[0], Pair[1]);
    355367    end;
    356368
     
    367379  Result := '';
    368380  for I := 0 to Count - 1 do
    369     Result := Result + '&amp;' + Names[I] + '=' + ValueFromIndex[I];
     381    Result := Result + '&amp;' + Keys[I] + '=' + Items[I].Value;
    370382  Result := Copy(Result, 6, Length(Result));
    371383end;
     
    387399      Pair.Explode(Parts[I], '=', StrToStr);
    388400      if Pair.Count >= 2 then
    389         Values[Trim(Pair[0])] := Trim(Pair[1]);
     401        Add(Trim(Pair[0]), Trim(Pair[1]));
    390402    end;
    391403  finally
     
    401413  Result := '';
    402414  for I := 0 to Count - 1 do
    403     Result := Result + '; ' + Names[I] + '=' + ValueFromIndex[I];
     415    Result := Result + '; ' + Keys[I] + '=' + Items[I].Value;
    404416  Result := Copy(Result, 2, Length(Result));
    405417end;
     
    447459destructor THTTPHandlerData.Destroy;
    448460begin
    449   Request.Free;
    450   Response.Free;
    451   Session.Free;
    452   inherited Destroy;
     461  FreeAndNil(Request);
     462  FreeAndNil(Response);
     463  FreeAndNil(Session);
     464  inherited;
    453465end;
    454466
  • trunk/Packages/CoolWeb/WebServer/UHTTPServerCGI.pas

    r84 r100  
    133133      // Generate cookies
    134134      for I := 0 to Cookies.Count - 1 do
    135         Headers.Add('Set-Cookie', Cookies.Names[I] + '=' + Cookies.ValueFromIndex[I]);
     135        Headers.Add('Set-Cookie', Cookies.Keys[I] + '=' + Cookies.Items[I].Value);
    136136        // + ';path=/;expires=' + RFC822DateTime(Now);
    137137
  • trunk/Packages/CoolWeb/WebServer/UHTTPServerTCP.pas

    r99 r100  
    121121      // Handle cookies
    122122      for I := 0 to Cookies.Count - 1 do
    123         Headers.Add('Set-Cookie', Cookies.Names[I] + '=' + Cookies.ValueFromIndex[I]);
     123        Headers.Add('Set-Cookie', Cookies.Keys[I] + '=' + Cookies.Items[I].Value);
    124124        // + ';path=/;expires=' + RFC822DateTime(Now);
    125125
  • trunk/Packages/CoolWeb/WebServer/UHTTPSessionFile.pas

    r84 r100  
    5858begin
    5959  with HandlerData do begin
    60     if Request.Cookies.IndexOfName(SessionIdCookieName) <> -1 then begin
     60    if Request.Cookies.SearchKey(SessionIdCookieName) <> -1 then begin
    6161      SessionId := Request.Cookies.Values[SessionIdCookieName];
    6262    end else begin
  • trunk/Packages/CoolWeb/WebServer/UHTTPSessionMySQL.pas

    r84 r100  
    6868begin
    6969  with HandlerData do begin
    70     if Request.Cookies.IndexOfName(SessionIdCookieName) <> -1 then begin
     70    if Request.Cookies.SearchKey(SessionIdCookieName) <> -1 then begin
    7171      SessionId := Request.Cookies.Values[SessionIdCookieName];
    7272    end else begin
  • trunk/Packages/TemplateGenerics/Generic/GenericDictionary.inc

    r84 r100  
    9999    Result := Result + 1;
    100100  end;
     101  if Result >= Count then Result := -1;
    101102end;
    102103
Note: See TracChangeset for help on using the changeset viewer.