Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8051181
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T07:14:51+00:00 2026-06-05T07:14:51+00:00

Currently I want to redirect specific Post requests using Indy10 TIdHTTPProxyServer. I followed the

  • 0

Currently I want to redirect specific Post requests using Indy10 TIdHTTPProxyServer. I followed the page

http://embarcadero.newsgroups.archived.at/public.delphi.internet.winsock/200904/0904301714.html

and wrote a simple sample as follow.

oid __fastcall TForm3::MyProxyHTTPBeforeCommand(TIdHTTPProxyServerContext *AContext)
{

    if (AContext->Target == "http://example.com/need_redirect_url" ) {

        TIdIOHandler* io = AContext->Connection->IOHandler;

        io->WriteLn("HTTP/1.0 302 Moved Temporarily");
        io->WriteLn("Location:  http://exampledomain.com/target_url");
        io->WriteLn("Connection: close");    
    }
}

It works if I press the “http://sample.com/need_redirect_url” into the URL bar of the browser.
But return nothing(No matter Post or Get) if it is a XMLHttpRequest which is targeted to the same URL.

I have to admit I am really unfamiliar with how HTTP works. And I also wonder if there is any better way to do what I want.

Although I am using C++Builder XE2. Delphi samples are also appreciated as there are less examples using indy components using C++

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T07:14:52+00:00Added an answer on June 5, 2026 at 7:14 am

    Your code is not writing a blank line that terminates the HTTP headers you are sending. You will also need to throw an exception to prevent TIdHTTPProxyServer from navigating to the client’s requested URL after the OnBeforeCommand event handler exits.

    Try this:

    void __fastcall TForm3::MyProxyHTTPBeforeCommand(TIdHTTPProxyServerContext *AContext) 
    { 
        if (AContext->Target == "http://xxx.com/need_redirect_url" )
        { 
            TIdIOHandler* io = AContext->Connection->IOHandler; 
    
            io->WriteLn("HTTP/1.0 302 Moved Temporarily"); 
            io->WriteLn("Location: http://mydomain.com/target_url"); 
            io->WriteLn("Connection: close");     
            io->WriteLn("");     
    
            Abort();
        } 
    } 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to pass a few variables to another page. Currently I'm using response.redirect
I am currently developing a Rack-based application and want to redirect all file requests
I am very new to C++ on Embarcadero XE2. Currently I want to transfer
Depending on the subdomain I want to call a specific controller. What I currently
Got a question about using mod_rewrite to redirect specific subdomains to use another domain.
i want to redirect a page and attach json data with it. i am
Problem 1: I want to redirect the kernel log to other file using my
Currently we are using the following code in .htaccess to redirect users from mydomain.com
I'm currently using Wordpress as a blogging platform but I want to change to
I'm currently building a site where I want anonymous users to see a page

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.