indy

Http Post with indy

拥有回忆 提交于 2019-11-27 15:05:52
I have a simple php script on my web server which I need to upload a file using HTTP POST, which I am doing in Delphi. Here is my code with Indy but aparantely it won't work and I can't figure out what i am not doing properly. How can I view what I send on the server is there such a tool ? procedure TForm1.btn1Click(Sender: TObject); var fname : string; MS,dump : TMemoryStream; http : TIdHTTP; const CRLF = #13#10; begin if PromptForFileName(fname,'','','','',false) then begin MS := TMemoryStream.Create(); MS.LoadFromFile(fname); dump := TMemoryStream.Create(); http := TIdHTTP.Create(); http

Indy 10 Http Server sample

妖精的绣舞 提交于 2019-11-27 13:05:44
问题 I need a simple code sample for Indy 10 Http Server When request (post) simply displays it Is there an Indy 9 sample for this? Thanks 回答1: Start a new VCL Forms project Drop a TidHTTPServer component onto the Form Double-click the form to create an OnCreate() event and activate the server IdHTTPServer1.Active := True; Back on the form, select the HTTP Server component, and create an OnCommandGet event In this OnCommandGet event (which is called within a child thread whenever a GET/POST occurs

Download a File from internet programmatically with an Progress event using Delphi and Indy

梦想的初衷 提交于 2019-11-27 10:36:22
问题 I need a way to download a file from the Internet using Delphi via HTTP, Which include an Progress event, I'm looking for a method which uses the Indy components. I am using Delphi 7. 回答1: I've coded this example, using just one HTTP GET, with Indy 10, hope it works with Indy 9 too: uses {...} IdHTTP, IdComponent; type TFormMain = class(TForm) {...} private {...} procedure HttpWork(ASender: TObject; AWorkMode: TWorkMode; AWorkCount: Int64); end; {...} procedure TFormMain.Button1Click(Sender:

Why are files sometimes a different size or corrupt after transferring by FTP?

◇◆丶佛笑我妖孽 提交于 2019-11-27 08:03:06
问题 I'm having a problem downloading a file using the TidFTP component in Delphi XE2. I am able to get a connection to the FTP site, get a list of files and perform the get command. However, when I try to download a file using the get command the file always downloads larger than the source file. Then the subsequent file is corrupt. Additionally, if I try to download multiple files, the first file downloads (larger than the source) and the remaining files are skipped. No error is thrown from the

How to check URL with IdHTTP?

人走茶凉 提交于 2019-11-27 07:08:53
How can I check for the target URL for specific response code like 200 OK without Indy throwing all sorts of exceptions out. ConnectionTimeout,ConnectionClosedGracefully, etc... For example if URL is not proper or its host cannot be found or cannot be reached. Indy will still rise exceptions even though i tried to ignore them. So my question is how to properly ignore these exceptions. 1. How to ignore all exceptions thrown by the TIdHTTP ? To handle all exceptions and, as you say, ignore them, you may use the code that is almost identical to the code from @Stijn's answer: procedure TForm1

How do I create an IHTMLDocument2 using a string from TIdHTTP?

二次信任 提交于 2019-11-27 07:06:43
问题 I download a URL with IdHTTP.Get , and I need to search the HTML tags and extract some data. How I can convert the string that IdHTTP.Get returns into an IHTMLDocument2 ? 回答1: Try this one: uses ... Variants, MSHTML, ActiveX; var Cache: string; V: OleVariant; Doc: IHTMLDocument2; begin ... Cache := IdHTTP.Get(url); Doc := coHTMLDocument.Create as IHTMLDocument2; // create IHTMLDocument2 instance V := VarArrayCreate([0,0], varVariant); V[0] := Cache; Doc.Write(PSafeArray(TVarData(v).VArray));

How to get images from URL in Delphi

杀马特。学长 韩版系。学妹 提交于 2019-11-27 05:55:11
问题 I am looking for any code samples that show how to pull images from URL into Delphi TImage component. Thanks, 回答1: With help of TMemoryStream and Indy component. uses GIFImg; procedure TForm1.btn1Click(Sender: TObject); var MS : TMemoryStream; GIf: TGIFImage; begin MS := TMemoryStream.Create; GIf := TGIFImage.Create; try IdHTTP1.get('http://www.google.com/intl/en_ALL/images/logo.gif',MS); Ms.Seek(0,soFromBeginning); Gif.LoadFromStream(MS); img1.Picture.Assign(GIF); finally FreeAndNil(GIF);

WWW server reports error after POST Request by Internet Direct components in Delphi

北城余情 提交于 2019-11-27 05:33:38
I'm using Delphi XE4 and i usually use Indy with IdHttp.POST to POST request to websites, This time, whenever i try to POST the request i get Error: Your browser is not sending the correct data. I'm very sure that I'm POSTing the right data, and i'm using the IOHandler and CookieManager. Been dealing with this for days(literally) Here is the code(the site in the code): procedure TForm1.Button1Click(Sender: TObject); var s, lge, Kf1, Kf2, Kf3, Kf4 : String; lParam : TStringList; begin S := http.Get('https://www.neobux.com/m/l/'); Memo1.Lines.Add(S); getParamLge(s,lge,'lge'); GetInput(s,Kf1,'id=

Step by step upgrade of Indy 10 in Delphi 2009

試著忘記壹切 提交于 2019-11-27 04:25:43
Can someone help in telling the details on how to uninstall Indy 10 and install the latest build? I found it http://indy.fulgan.com/ZIP/IndyTiburon.zip There is a similar question , but not a satisfying answer, just some comments from the user who asked, but that is not a step by step guide. Why there is not a tool for this? Mark Robinson I did this very recently, I've done it before with 2007 and had lots of problems, but this time in D2010 it went really well... Assumptions: The Indy BPL's are stored in the bin folder DCP and DCU are stored in the lib\indy10 folder Source code is source\indy

Delphi: Indy - how to get the response body on error?

泄露秘密 提交于 2019-11-27 02:49:09
问题 Delphi6 and XE3. I want to get the real response body of a request. But the server makes error 500. Then the Indy replace the response text with the description of the error. This homepage is designed for answer 500 in non abnormal operations too, and we need to determine what to do from response text. Could I get the response text from IdHTTP or from an Exception object when the status code is 500? Thanks for any info! 回答1: When TIdHTTP encounters a server error, it raises an