Re: [twsocket] Minor omission fixed for improved Web-server operation
What's the scenario where I need to change the mime type after I have searched for it already? So the application can easily check what actual MIME type has been used, and dynamically change it if incorrect. That's an unneeded double-check. If you are providing the MimeTypesList, you will make sure in the first place, adding to it the MIMEs you need, the MIME type for the document to be sent is the one you want to use. I see the OnHttpMimeContentType event as a different method to add my own implementation of the MIME assignation mechanism, that defaults to the internal DocumentToContentType function if event and MimeTypesList are not assigned. The component has excess of these Triggerxxx methods. Because it's evolved over 15 years of development, different developers use it in different ways, and we try to keep it backward compatible to avoid breading existing applications. But you are still adding these "empty" trigger functions to new added functionality, so what's the point? These overridable, by descendants, methods are only needed if the class has code in that trigger method, so descendants can change the behavior of it. Currently, most of these trigger functions only check if an event is assigned, and call it if yes. But I don't know the component internals as you, so I may be missing something... -- 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] Minor omission fixed for improved Web-server operation
> What's the scenario where I need to change the mime type after I > have searched for it already? So the application can easily check what actual MIME type has been used, and dynamically change it if incorrect. > The component has excess of these Triggerxxx methods. Because it's evolved over 15 years of development, different developers use it in different ways, and we try to keep it backward compatible to avoid breading existing applications. 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] Minor omission fixed for improved Web-server operation
On 10-11-2012 14:42, Stan wrote: I think loading hundreds of types from Registry when 'js' is missing in the default list is overkill, because most of them are not Internet-involved. It don't takes that long, but even so It's also my opinion..., If it's not needed, don't do it. Because of this (I don't need the extra functionality of the TMimeTypesList) I'm using THttpServer.OnHttpMimeContentType event. But even so, this event is being called after an extra, IMHO not needed if event assigned, call to the internal and obsolete DocumentToContentType procedure Current code: if Assigned (FServer.MimeTypesList) then FAnswerContentType := FServer.MimeTypesList.TypeFromFile(FDocument) { V7.46 } else FAnswerContentType := DocumentToContentType(FDocument); TriggerMimeContentType(FDocument, FAnswerContentType); { V7.41 allow content type to be changed } What's the scenario where I need to change the mime type after I have searched for it already? Better would be: TriggerMimeContentType(FDocument, FAnswerContentType, handled); if not handled then if Assigned (FServer.MimeTypesList) then FAnswerContentType := FServer.MimeTypesList.TypeFromFile(FDocument) { V7.46 } else FAnswerContentType := DocumentToContentType(FDocument); Even better would be: FAnswerContentType := 'application/binary'; if Assigned(FOnMimeContentType) then FOnMimeContentType(Self, FileName, ContentType) else if Assigned (FServer.MimeTypesList) then FAnswerContentType := FServer.MimeTypesList.TypeFromFile(FDocument) { V7.46 } else FAnswerContentType := DocumentToContentType(FDocument); The component has excess of these Triggerxxx methods. -- 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] Minor omission fixed for improved Web-server operation
> I think loading hundreds of types from Registry when 'js' is > missing in the default list is overkill, because most of them > are not Internet-involved. Everyone has different requirements, TMimeTypeList is designed to support email as well where many different file types may get sent as attachments. The lack of application/javascript, must look at IIS to see how it handles such files. > now I'd propose to revise TMimeTypeList.Create, > where the default types are registered, and populate it with the > omitted types, which should be there by default, imho. That can be done. 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] Minor omission fixed for improved Web-server operation
Thanks, I'm using v 7.51, but somehow overlooked new demo and thought the mime-type related component (and your comments) are for optional usage, that is it allows for providing additional types which are rare and application specific. Javascript is not in this number, obviously, so I supposed it should be supported rightaway by the core. I think loading hundreds of types from Registry when 'js' is missing in the default list is overkill, because most of them are not Internet-involved. So basicly, my suggestion remains almost the same but just changes its landing point: now I'd propose to revise TMimeTypeList.Create, where the default types are registered, and populate it with the omitted types, which should be there by default, imho. Best wishes, Stan - Original Message - From: "Angus Robertson - Magenta Systems Ltd" To: Sent: Saturday, November 10, 2012 2:57 PM Subject: Re: [twsocket] Minor omission fixed for improved Web-serveroperation Did you mean obsolete in V8 trunk? In the latest stable V7 it is used by default. It was added in V7.46. The old stuff is left behind for backward compatibility but will not be enhanced which is what you requested. It's not clear how to switch to the mode that mime-types to be read from Windows Registry by default? You drop TMimeTypesList onto the form and attach it to all your server instances, or add it in code. Look at the OverbyteIcsWebServ demo to see how it's attached, and OverbyteIcsMimeDemo allows you to see what MIME types it picks up from the registry and how to modify the list. The registry does include: .svg=image/svg+xml but not application/javascript, although it is in the mime.types files used as an alternative. Or you can add it using the AddContentType method. 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 -- 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] Minor omission fixed for improved Web-server operation
> In the module OverbyteIcsHttpSrv.pas, in the function > DocumentToContentType This function is now obsolete, the latest versions of the web server use the new TMimeTypesList component which takes mapping from the Windows classes registry, from a file or allows you to add your own extra MIME types. 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
[twsocket] Minor omission fixed for improved Web-server operation
Hi, everybody, I propose a little but important fix for web-server component implementation. In the module OverbyteIcsHttpSrv.pas, in the function DocumentToContentType, just before the default latest clause with else Result := 'application/binary'; there should be added the following lines: else if Ext = 'svg' then Result := 'image/svg+xml' else if Ext = 'js' then Result := 'application/javascript' Without proper content type support for 'js' most of web-application do not work when hosted on a ICS-based web-server. SVG became a wide-spread image format nowadays. I think these types must be supported by ICS core out-of-the-box. Best wishes, Stan -- 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