delphicookieswebrequestisapi-extension

Cookie size limit. Large cookies


I'm using ISAPI DLL and met a situation when the DLL's TWebRequest.Cookie shows no cookies at all if total cookie size is greater than 4096 bytes. Is there a way to handle large cookies?


Solution

  • In Delphi, there is no way, unless you implement your own ISAPI layer (something that IntraWeb does). Everything based on built-in ISAPI layer (TISAPIRequest/TISAPIResponse) cannot handle it, because of how it retrieves the cookie field from the request. The method is TISAPIRequest.GetFieldByName() (unit Web.Win.IsapiHTTP):

    function TISAPIRequest.GetFieldByName(const Name: AnsiString): AnsiString;
    var
      Buffer: array[0..4095] of AnsiChar;
      ...
    begin
      ...
    end;
    

    Please notice that Buffer var - which will get the actual data - is limited to 4096 bytes. That's why you can only receive this amount of data in your cookie. I don't see how you can receive more data, unless you split it into more than one cookie.You can also send data using custom fields (which are much easier to create/manipulate from the browser side), like "X-Example-Your-Data: abcde" (also limited to 4096 bytes). You can retrieve this data using the same GetFieldByName() method.