Why are you reading the client's request data in the
TIdHTTPProxyServer.OnConnect event? You should not be doing that at all. You are reading the request line that specifies the HTTP method and URL being requested by the client, which means that line is no longer available for
TIdHTTPProxyServer to read, so it won't know how to process the request correctly.
If you want access to the client's request headers, you need to either:
- use the TIdHTTPProxyServer.OnHTTPBeforeCommand event
- set the TIdHTTPProxyServer.TransferMode property to tmFullDocument and use the TIdHTTPProxyServer.OnHTTPDocument event
Either way, the client's request headers will be in the provided
TIdHTTPProxyServerContext object's
Headers property when its
TransferSource property is
tsClient.
Also,
TIdHTTPProxyServer is a multi-threaded component. Its events are fired in the context of worker threads, not in the main UI thread. As such, you cannot safely access UI controls
directly like you are. You MUST synchronize with the main UI thread, such as with the RTL's
TThread.Synhronize() or
TThread.Queue() methods, or Indy's
TIdSync or
TIdNotify classes.