views:

130

answers:

3

I am looking for a method to intercept http post requests with delphi without hooking any browser functions.Is that possible? How??

+1  A: 

You'd have to create an application that acted like a local Proxy Server that caught all requests made and then forwarded them out to the appropriate server.

I'm not sure which version of Delphi you're using, but you might want to check out this sample Proxy Server in C# and see if you can port the basics to suit your needs.

Justin Niessner
i would appreciate an example that is not written in .NET
opc0de
@opc0de - Understandable. Which language would you prefer though (I attempted to find Delphi but couldn't).
Justin Niessner
C++ , ASM works ;)
opc0de
Look into the Indy library, there's an HTTP Proxy component - with full source code. Remember anyway that a proxy has to be set in the browser settings. You can also code a "transparent" proxy, but that requires that all HTTP traffic is routed to the proxy, to achieve it you have to work at the network layer (i.e. writing a filter driver, but that's not easily doable in Delphi, may require C/C++ and the Driver Development kit)
ldsandon
there's always IdHttpProxyServer
glob
+2  A: 

In stead of doing this in Delphi, you might want to consider good and scripteable free solutions like Http Fiddler?

Edit:

If you want to write a proper and fully fledged proxy from scratch, that works well with most of the idiosyncrasies of possible http clients and servers, be prepared for at least a couple of man-months work.

If you are willing to use at least some base libaries, then look into this question.

--jeroen

Jeroen Pluimers
i want to learn how to do it that's the point.
opc0de
See my edited answer. Good luck!
Jeroen Pluimers
+4  A: 

You could use something like WinPCap to grab intercept all packets looking specifically for packets on port 80 using the http protocol with a POST. There is a Delphi wrapper available which might be of some help. This is the same engine that is used by WireShark which would be useful by itself if your just having to do this manually or to debug an existing protocol.

skamradt