Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update IdCustomHTTPServer responses #520

Open
pressanykey101 opened this issue Jan 16, 2024 · 1 comment
Open

Update IdCustomHTTPServer responses #520

pressanykey101 opened this issue Jan 16, 2024 · 1 comment
Labels
Element: HTTP Issues related to HTTP handling, TIdHTTP, TIdHTTPServer, TIdHTTPProxyServer, etc Status: Deferred Issue to be re-reviewed in a future release Type: Enhancement Issue is proposing a new feature/enhancement
Milestone

Comments

@pressanykey101
Copy link

pressanykey101 commented Jan 16, 2024

Found myself in need for response 308 Permanent Redirect.
Don't see an easy way to extend/override TIdHTTPResponseInfo.SetResponseNo functionality. It would be nice to have an ability to upload a list of responses with corresponding text messages as a list or array at or after TIdHTTPServer creation.

@pressanykey101 pressanykey101 added Status: Reported Issue has been reported for review Type: Enhancement Issue is proposing a new feature/enhancement labels Jan 16, 2024
@rlebeau rlebeau added the Element: HTTP Issues related to HTTP handling, TIdHTTP, TIdHTTPServer, TIdHTTPProxyServer, etc label Jan 17, 2024
@rlebeau
Copy link
Member

rlebeau commented Jan 17, 2024

In an OnCommand... event handler, you can manually set the response's ResponseNo and ResponseText properties (in that order) to whatever values you want. The ResponseNo property setter will assign a default string to the ResponseText, based on HTTP standards, but you can just overwrite that value with your own string, eg:

AResponseInfo.ResponseNo := 308;
AResponseInfo.ResponseText := 'Permanent Redirect';

That being said, allowing the user to customize the default ResponseText strings is an interesting idea, but it will have to wait for a future release since that is a whole new feature set to add (new properties, design-time editing, etc).

But, in the meantime, I have updated the ResponseNo setter to now include default ResponseText strings for a bunch of new status codes, including 308.

rlebeau added a commit that referenced this issue Jan 17, 2024
Updating TIdHTTPResponseInfo.SetResponseNo() to assign a default ResponseText string to every HTTP status code that is currently registered with IANA.
@rlebeau rlebeau added Status: Deferred Issue to be re-reviewed in a future release and removed Status: Reported Issue has been reported for review labels Jan 17, 2024
@rlebeau rlebeau added this to the Indy 12 milestone Jan 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Element: HTTP Issues related to HTTP handling, TIdHTTP, TIdHTTPServer, TIdHTTPProxyServer, etc Status: Deferred Issue to be re-reviewed in a future release Type: Enhancement Issue is proposing a new feature/enhancement
Projects
None yet
Development

No branches or pull requests

2 participants