-
Content Count
2684 -
Joined
-
Last visited
-
Days Won
113
Everything posted by Remy Lebeau
-
I have checked in a new branch with some changes for TIdHTTPProxyServer: https://github.com/IndySockets/Indy/tree/http-proxy-keepalive Let me know if it works OK, and then I'll merge it in to the main code. I also opened a ticket in Indy's repo: https://github.com/IndySockets/Indy/issues/425
-
No, there is not. Handling CONNECT is very different than handling other HTTP verbs. A CONNECT request just contains the target host/port to connect to, and then all data between client and target server is tunneled back and forth as-is. But any other HTTP verb is a full HTTP request sent to the proxy itself, containing the full target URL, so the proxy will have to parse and forward the request as needed. And HTTP proxies are allowed to modify a request and/or response as it wants (unless the client asks the proxy not to do that, but TIdHTTPProxyServer does not implement that feature at this time). If you want a straight passthrough, look at TIdMappedPortTCP instead. But to make that work as an HTTP proxy, you will have to parse the HTTP protocol manually in its OnConnect, OnExecute, and OnOutboundData events. That is the default behavior for HTTP 0.9 and HTTP 1.0, but in HTTP 1.1 onward the default behavior is to keep the connection open instead, and the client has to explicitly ask the remote server to close the connection after sending a response. Looking at TIdHTTPProxyServer again, I see it uses HTTP 1.0 when communicating with the remote server, so it closes the remote connection after each response, and it will also close the connection with the requesting client after each response too. I'll have to update TIdHTTPProxyServer to support keep-alives. A CONNECT is a straight passthrough of raw data back and forth, the proxy does not process the data in any way. That is not the case when handling other HTTP verbs. That is incorrect. If the response has a 'Connection: keep-alive' (HTTP 0.9/1.0) header, or does not have a 'Connection: close' (HTTP 1.1+) header, the HTTP client is required by the HTTP specs to parse the response to discover when it actually ends, specifically because a disconnect WON'T occur at the end in that situation. Makes sense, as TIdHTTPProxyServer does not support keep-alives at this time. I'll have to update it to handle the 'Connection' and 'Proxy-Connection' headers better. It shouldn't even be getting that far, since the disconnect should happen before TIdHTTPProxyServer attempts to read the next request from the client. Yes, because TIdCommandHandler.Disconnect is set to True in TIdHTTPProxyServer.InitializeCommandHandlers() for all proxy requests. Good to know, thanks. Currently, it does, because TIdHTTPProxyServer does not implement proper handling of HTTP keep-alives at this time. Though, it doesn't really seem to be handling non-keepalives properly, either. It should be passing around 'Connection: close' and 'Proxy-Connection: close' headers, at least until keep-alives can be implemented. Not that I can think of. The proxy uses HTTP 1.0 to communicate with the remote server, so it already disconnects from the server after each response. As long as the client wants to stay connected to the proxy, it could send subsequent requests to the proxy, and each one will be forwarded individually. Though, I would not suggest setting Disconnect=False in TIdHTTPProxyServer.InitializeCommandHandlers(). I would leave it as True as a fallback, and then set TIdCommand.Disconnect=False inside of TIdHTTPProxyServer.CommandPassThrough() after reading the client's request headers, so that the keep-alive can be handled on a per-request basis. I'll update TIdHTTPProxyServer to handle that. I know what CONNECT is. And what you describe is how TIdHTTPProxyServer handles CONNECT right now. But an HTTP client won't use CONNECT for HTTP verbs like HEAD/GET/POST unless they are used over HTTPS, since CONNECT is required to let the client negotiate SSL/TLS security directly with the remote server through an HTTP proxy. Otherwise, the client would be negotiating SSL/TLS with the proxy instead, which would then subject the requests to MITM attacks.
-
Playing an MP4 animation / unsupported media file / cppbuilder
Remy Lebeau replied to alank2's topic in FMX
Related: Getting exception HRESULT: 0x80040265 with MP4 Files -
It would be nice if the "Call started" and "Call completed" messages logged WHAT operation(s) were being started/completed. And also, if every Call start/sent/reading message included the PeerPort that is processing the Call, to better differentiate between Calls that overlap in parallel. The Call numbers alone are making it confusing which client is performing which action when Calls overlap. Logging the PeerPort instead on everything should remove that ambiguity. Is it possible/expected that any given "Call" in your client code produces multiple HTTP requests at a time? Or, is it expected to be only 1 HTTP request per "Call"? Connections to the target server are not re-used. There is 1 new connection per request forwarded. The connection with a client stays open as log as the client wants. There can be multiple requests per connection to the proxy. And your client is requesting keep-alives with the proxy, though most connections are sending only 1 request per connection. But Call 6 appears to share a TCP connection with an unknown Call number, and that 2nd call is difficult to determine what is actually happening on it. It might have hung, or not, I can't tell yet. I can't comment on that, since I don't see that in your code. Possibly, if the client uses HTTP keep-alives to reuse a connection for multiple HTTP requests. As it does appear really happened for at least 2 Calls. It is certainly possible that TIdHTTPProxyServer may not be handling that situation correctly, since it is not a fully functional HTTP server. I might have to force "Connection: close" on every response until that can be verified/addressed. Synchronize what, exactly? It should not be. Provided you are not blocking the exception then all Indy servers should be handling it to close the socket and stop the thread. No. I have not looked at the 2nd log yet, I will do so shortly. The 1st log was not easy to follow. But this does go back to my comment above that there possibly could be an issue with TIdHTTPProxyServer not correctly handling multiple requests on the same TCP connection through HTTP keep-alives. That only applies to the listening Binding sockets, to reuse ports that were previously closed and then reopened in a short amount of time.
-
Conditional compiling - Delphi has a bug
Remy Lebeau replied to KodeZwerg's topic in RTL and Delphi Object Pascal
This seems to be the opposite of documented behavior in Delphi: https://docwiki.embarcadero.com/RADStudio/en/IF_directive_(Delphi) So, {$IF FPC_VERSION >= 3} SHOULD just evaluate to False, and if it is not then this is likely a regression.- 5 replies
-
- delphi
- conditional
-
(and 1 more)
Tagged with:
-
Playing an MP4 animation / unsupported media file / cppbuilder
Remy Lebeau replied to alank2's topic in FMX
Did you make sure they were successful? In any case, I'm not sure this IS the root cause, only that it is ONE POSSIBLE cause. Like I mentioned, there are other reasons for that error to occur. I suggest you enable Debug DCUs and step into the FMX source code with the debugger to see what is REALLY happening inside the TMediaPlayer. Not that I'm aware of. MP4 is one of the supported file extensions on Windows. But that does not rule out the possibility that the MP4 file itself is bad in some way. -
Playing an MP4 animation / unsupported media file / cppbuilder
Remy Lebeau replied to alank2's topic in FMX
Make sure CoInitialize() or CoInitializeEx() is being called at program startup. -
Playing an MP4 animation / unsupported media file / cppbuilder
Remy Lebeau replied to alank2's topic in FMX
That error happens if TMediaPlayer can't instantiate DirectShow's Graph Builder object (did you initialize the COM library beforehand?), or can't query the builder for the necessary video renderer interfaces, or the builder can't load the file to render it. -
I don't understand what this log is supposed to be showing me. Looks like every request received is responded to, and each connection is closed. What am I missing? What is the actual problem, exactly? Using HTTPS through an HTTP proxy requires use of the CONNECT verb, which is just a straight passthough tunnel of raw data from the client to the target server and back. TIdHTTPProxyServer does not attempt to interpret the raw data in any way, all it is doing is managing the 2 TCP connections involved. Whereas, using HTTP through an HTTP proxy requires sending HTTP requests to the proxy itself, and then the proxy makes its own HTTP requests to the target server. So TIdHTTPProxyServer by default is fully reading and interpreting your client's requests and then replicating them to the target server. So sure, there could certainly be some glitches in that process. TIdHTTPProxyServer is not a full HTTP server or HTTP client, it is quite bare-bones, so it is not outside the realm of possibility that RemObjects is sending its HTTP requests in a way that TIdHTTPProxyServer can't handle correctly. Or, because TIdHTTPProxyServer uses HTTP 1.0 when communicating with the target server, there could be differences between its use of HTTP 1.0 and the client's use of HTTP 1.1 that is causing interference. Hard to say for sure. I'm speculating, because I have no way to actually test/debug this at the moment. Something else to consider - by default, TIdHTTPProxyServer.DefaultTransferMode is set to tmFullDocument, which means for GET/POST/HEAD requests, TIdHTTPProxyServer will read the client's entire request into memory before then passing it along to the target server, and then read the server's entire response into memory before then passing it along to the client. This allows the user's application code to modify the request/response data if desired before passing it along. Do you have the same problem if you set TIdHTTPProxyServer.DefaultTransferMode to tmStreaming instead? That will cause TIdHTTPProxyServer to not buffer the request/response data in memory, it will be passed along as it is being received (at the cost that application code can't modify it anymore).
-
Delphi CE 10.4.2 - Command Line Compilation
Remy Lebeau replied to PawelPepe's topic in Delphi IDE and APIs
Well, that sucks -
exceptions and static storage duration objects
Remy Lebeau replied to Fraser's topic in General Help
I'm just going off of the actual code you posted earlier. That tends to happen when the runtime/debugger can't interpret the actual exception object at the level it was detected at, basically treating it as an "unknown" exception type. Did you not see the quote I posted earlier? https://en.cppreference.com/w/cpp/language/function-try-block Minor nitpicks: the A() constructor is not public, and std::exit() takes an exit code integer instead of a string as input. In any case, when I test the code outside of C++Builder (which I don't have installed at the moment), the code works fine when using std::exit() in the function-try's catch handler: https://onlinegdb.com/WqiBtg8dD https://onlinegdb.com/v7B8acNo4 And terminates the process with a re-thrown exception when not using std::exit() in the handler: https://onlinegdb.com/q0KLc6Cne https://onlinegdb.com/rHqvw5kmo -
Playing an MP4 animation / unsupported media file / cppbuilder
Remy Lebeau replied to alank2's topic in FMX
What is the actual error? What version of C++Builder are you using, and what platform(s) are you attempting to play the MP4 on? Did you verify the MP4 is valid to begin with? Can you play it with other software players? What kind of artifacts? -
delphi LabView DLL creates weird double array
Remy Lebeau replied to Snieres's topic in Algorithms, Data Structures and Class Design
I just answered that on StackOverflow, go see my update. -
delphi LabView DLL creates weird double array
Remy Lebeau replied to Snieres's topic in Algorithms, Data Structures and Class Design
<sigh> And here we go again... This is a followup to these StackOverflow questions: https://stackoverflow.com/questions/73313071/ https://stackoverflow.com/questions/73254575/ -
Good example of what exceptions TIdHTTP cielt can raise
Remy Lebeau replied to Tommi Prami's topic in Indy
Indy has a few hundred unique exception classes defined, so it is not really feasible to give you a comprehensive list of them all. However, most of them are specialized to specific components only, so you don't have to worry about most of them. All Indy exceptions are derived from EIdException. And then for TIdHTTP specifically, you could potentially get any of the following derived exceptions raised (this is not an exhaustive list, there might be others I missed): EIdHTTPProtocolException (HTTP error response from server) EIdUnknownProtocol (requesting a non-HTTP/S URL with no target port specified) EIdIOHandlerPropInvalid (requesting HTTPS URL but no SSLIOHandler is assigned) EIdReadTimeout EIdSocketError (base class for all socket-related exceptions, may also be raised as-is) EIdInternetPermissionNeeded (Android only, for now) EIdConnClosedGracefully EIdClosedSocket EIdNotConnected EIdNotASocket What is wrong with just catching Exception/EIdException and displaying its Message property? Mosst Indy exceptions have message texts assigned to them. -
In which case, you should be getting an EConvertError exception raised, not a corrupted/empty file created.
-
exceptions and static storage duration objects
Remy Lebeau replied to Fraser's topic in General Help
There is no call to exit() in the code you presented. In the code you presented, you have 2 separate object instances of the A class: A a; // <-- here A & AccessA() { static A obj; // <-- here return obj; } The 1st object is being created in global scope during program startup, and the 2nd object is being created in static memory the first time AccessA() is called at runtime. The global object is created before your project's WinMain() function is executed The code presented is not calling AccessA() at all, so the compiler/linker is free to optimize it away, if it wants to. I already explained that in detail in my previous reply. Go re-read it again more carefully. Do you understand the difference between a function-try block and a normal non-function-level try block? No, there is no explicit re-throw statement in the catch block. But the catch block is performing an implicit re-throw, because you are using a function-try block instead of a normal try block: If you really want to swallow the exception, use a normal try block instead of a function-try block, eg: class A { A() noexcept { try { throw std::logic_error("test"); } catch (std::exception const &ex) { std::cout << "Caught an STL exception" << std::endl; } } }; Notice the try-catch is now inside the constructor's body, rather than around the body as in your original example. -
That is normal behavior. That is also normal behavior. Calling conventions like cdecl and stdcall simply don't exist in 64bit, and they are ignored completely when used in code. There is only 1 standardized 64bit calling convention, and its behaviors are dictated by the 64bit ABI. And the 64bit calling convention indeed does not use the same name mangling rules that the 32bit cdecl calling convention uses. Use a .DEF file to control how the linker (or IMPLIB tool) formats exported names, and what internal names those exported names map to.
-
exceptions and static storage duration objects
Remy Lebeau replied to Fraser's topic in General Help
I would not have expected this code to compile, but if it does then it has undefined behavior. You are using a function-try block around the constructor body. Even though you are catching an exception, a function-try implicitly re-throws every exception it catches, if you don't explicitly re-throw it yourself. But you marked the constructor as noexcept, promising it will never throw an exception. You broke the promise. At the very least, you need to get rid of the noexcept to get rid of the undefined behavior. You will still crash at startup, but that is because of another issue... Because the thrown exception is not actually being fully caught. You are constructing an A object in global scope before Winmain() is called, you are not waiting for AccessA() to be called first. That global object is throwing an exception that is not being caught, thus aborting the process startup. A thrown exception that is not caught by the throwing thread causes std::terminate() to be called, which ends the calling process. Likewise, if an exception escapes a noexcept function without being caught, std::terminate() is called as well. But the exception is not being swallowed by the catch handler, it is being re-thrown. -
You can't assign a WAN IP to a printer on the LAN side. If you are trying to access your LAN printer over the public Internet, you will have to setup port forwarding on your router to route incoming connections from a WAN IP/Port to the printer's LAN IP/Port. Then, as others have mentioned, there are plenty of external services you can query to get your current WAN IP. Otherwise, a better option is to just create a VPN into your LAN network, and then use the printer's LAN IP.
-
duplicate thread:
-
That is already set to True by default in new projects, but defaults to False in older projects migrated to newer IDEs.
-
I can't attest to the behavior of the OK and Cancel buttons. But one problem I see is your NewString variable. Where is it declared, and where is it used after the dialog closes? Remember, this dialog is asynchronous, so make sure you are not accessing NewString out of scope. Also, your 'with ASyncService' block is being wasted and should be removed.
- 9 replies
-
- fmx
- tdialogservice
-
(and 1 more)
Tagged with:
-
What is the meaning of the square bracket in here?
Remy Lebeau replied to stacker_liew's topic in RTL and Delphi Object Pascal
The question was about the SQUARE brackets (Attribute), not the ANGLE brackets (Generic). -
exceptions and static storage duration objects
Remy Lebeau replied to Fraser's topic in General Help
Without an example showing the error in action, it is hard to diagnose this.