Re: [twsocket] Suggestion for DocumentToContentType
> Is there a reason you placed the calls in this sequences? I used that sequence so the main application can check if the MIME type is correct and then change it, ie just handle exceptions. The default MIME code is not exactly processor intensive. > why the String parameters are not declared as const? My fault, I'll fix that today, but it will mean a package rebuild. Angus -- To unsubscribe or change your settings for TWSocket mailing list please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be
Re: [twsocket] Suggestion for DocumentToContentType
> Oct 21, 2011 V7.41 Angus added OnHttpMimeContentType to allow > custom ContentTypes to be supported for unusual file extensions. Very nice. Is there a reason you placed the calls in this sequences? I think procedure THttpConnection.SendDocument[..] begin ErrorSend := FALSE; ProtoNumber:= 200; TriggerMimeContentType(FDocument, FAnswerContentType); { V7.41 allow content type to be changed } if FAnswerContentType='' then // no callback or not handled? Let the default function do it's magic. FAnswerContentType := DocumentToContentType(FDocument); [..] is a little bit better (at least if you have a callback and a matching MimeContentType). In the worst case you have one additional comparism (FAnswerContentType='') in the best case the complete if..then..else construct of the default function will be skipped. It also would enable the user to replace the default function with a optimized search. BTW: what is the local variable "ErrorSend" good for? I think it simply can be kicked... Another minor thing: Is there a special reason why the String parameters (Filename) of the callbacks and the Trigger[..] procedures are not declared as const? This also applies to the DocumentToContentType function. Greetings Lars -- To unsubscribe or change your settings for TWSocket mailing list please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be
Re: [twsocket] Suggestion for DocumentToContentType
On 21-10-2011 19:18, Angus Robertson - Magenta Systems Ltd wrote: Oct 21, 2011 V7.41 Angus added OnHttpMimeContentType to allow custom ContentTypes to be supported for unusual file extensions. Seems to be working, but why the heck you call the internal DocumentToContentType, even if it is assigned a substitute method?! At least add an "Handled" variable, and just call the internal if not handled by the external one. Also, why the connection can't check if the event is assigned in its owner server, and call it directly? Why all these trigger... duplication calls. I suppose it's because this extended the sub-classing possibilities, but I don't see any advantage here, as there is no internal code to override. Or I'm missing something? I will look at getting MIME types from the registry, but maybe not for a week or so. That could be useful, but add it as a server Option. If in the options, charge an internal server ExtToContentType structure (on demand, for each new extension conversion). If not, don't spend cycles doing something not required by the application. -- To unsubscribe or change your settings for TWSocket mailing list please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be
Re: [twsocket] Suggestion for DocumentToContentType
> I also find myself with the need to edit the DocumentToContentType > function, each time I update my local copy of ICS. SVN has been updated with a new OverbyteIcsHttpSrv: Oct 21, 2011 V7.41 Angus added OnHttpMimeContentType to allow custom ContentTypes to be supported for unusual file extensions. The nightly zip will be available after midnight. I will look at getting MIME types from the registry, but maybe not for a week or so. Angus -- To unsubscribe or change your settings for TWSocket mailing list please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be
Re: [twsocket] Suggestion for DocumentToContentType
> I also find myself with the need to edit the DocumentToContentType > function, each time I update my local copy of ICS. > This has not being addressed yet I get annoyed every time I look at the list of MIME types as well, and have added to it myself in the past. I will do something better in the next day or two. Angus -- To unsubscribe or change your settings for TWSocket mailing list please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be
Re: [twsocket] Suggestion for DocumentToContentType
I also find myself with the need to edit the DocumentToContentType function, each time I update my local copy of ICS. This has not being addressed yet, so how about if, instead of the more complex implementation proposed here, an assignable OnDocumentToContentType property is added to the httpserver, so users can provide their own implementation of the DocumentToContentType function, if they need to provide other content types. The function is only called from the THttpConnection.SendDocument, so it will go as: procedure THttpConnection.SendDocument(SendType : THttpSendType; const CustomHeaders : String); if assigned(FServer.FOnDocumentToContentType) then FAnswerContentType :=FServer.FOnDocumentToContentType(FDocument) else FAnswerContentType := DocumentToContentType(FDocument); .. Hi Lars, Lars Gehre wrote: Hi, after getting chewed out (again!) for forgetting to extend the "DocumentToContentType" function after an update of ICS, I like to suggest an improvement. As base use a THashedStringlist (or something similar). Fill the list with the default extension/contentType names and values pairs and provide a public "RegisterContentType" procedure to add customized content types to the list. It might be actually faster (sorted list) than the old function... I agree. Maybe this is also the time to add "use the registry to find MIME type for file types" ;) AFAIK this is rather slow and if there were an option to register custom MIME types one could feed them from the registry into the hashlist once on server start? -- To unsubscribe or change your settings for TWSocket mailing list please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be
Re: [twsocket] Suggestion for DocumentToContentType
Hi Lars, Lars Gehre wrote: > Hi, > > after getting chewed out (again!) for forgetting to extend the > "DocumentToContentType" function after an update of ICS, I like to > suggest an improvement. > > As base use a THashedStringlist (or something similar). > Fill the list with the default extension/contentType names and values > pairs and provide a public "RegisterContentType" procedure to add > customized content types to the list. > It might be actually faster (sorted list) than the old function... I agree. > Maybe this is also the time to add "use the registry to find MIME > type for file types" ;) AFAIK this is rather slow and if there were an option to register custom MIME types one could feed them from the registry into the hashlist once on server start? -- Arno Garrels -- To unsubscribe or change your settings for TWSocket mailing list please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be