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 9077599
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T19:24:23+00:00 2026-06-16T19:24:23+00:00

I’m trying to create one transparent HTTP proxy . It’s purpose is to stay

  • 0

I’m trying to create one transparent HTTP proxy. It’s purpose is to stay between the browser and the web server and be invisible. Here is the code I’m using. Unfortunately it’s not working very well. When I open the web page (referenced by $base_uri) there are different results depending on that whether I’ve opened it using the browser only or the browser and the proxy. I’m trying it on a web site which is returning all kinds of responses including “transfer-encoding: chunked” (so I guess may be the problem could be there?!). I think that there could be also problems with the cookies but I don’t know how to solve them (if any…).

#!/usr/bin/perl

use strict;

use HTTP::Daemon;
use LWP::UserAgent;
use HTTP::Cookies;

my $cookie_jar = HTTP::Cookies->new();

my $ua = LWP::UserAgent->new( max_redirect => 0, env_proxy => 0,keep_alive => 1, timeout => 30, agent => "Mozilla/4.76 [en] (Win98; U)");
my $d = HTTP::Daemon->new( 
    LocalHost => "localhost",  # remove this to listen from other machines 
                   # (i.e. open-relay... be careful of spammers!)
    LocalPort => 33331
) || die;
print "[Proxy URL:", $d->url, "]\n";

fork(); fork(); fork();  # 2^3 = 8 processes

$ua->cookie_jar($cookie_jar);

my $base_uri = 'http://example.com/';

while (my $c = $d->accept) {
        while (my $request = $c->get_request) {
            my $uri = $base_uri . $request->uri->as_string();
            my $method = $request->method;
            my $req = HTTP::Request->new($method, $uri);

            $request->uri($uri);

            print "[[ $method >> $uri ]]\n";
            my $response = $ua->simple_request($request);
            $c->send_response( $response );
        }
    $c->close;
    undef($c);
}

Thank you in advance!

  • 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-16T19:24:24+00:00Added an answer on June 16, 2026 at 7:24 pm

    It is not clear, what you really want. You should describe it much better. If you describe what and why you need that proxy and what features it needs, any help can be much better. Nevertheless I’ll try.

    What you currently do is to take an incoming connection, extract the URI and the call method and pass it to your source. Well, HTTP is much more complex – you strip everything like the transported data (e.g. for POST requests) as well as all the header lines (cookies, login data, browser identification, language specs, …), which usually carry important information. Also you modify the timing behavior a lot. Then you sent it to your proxy target.

    Now you take the server answer and again strip everything relevant. Also you only reply the answer after it is finished. For streaming data this will not work (you already mentioned the chunked transfer mode). Also your method requires a lot of memory for large files (e.g. a DVD image – 4GB).

    Without further details about your application no real suggestion is possible, but some ideas:

    a) As told in the comments there are Perl modules available. You may test them and see if they fit your needs.

    b) You can go down a level. Use IO::Socket::INET or INET6 and directly work on the socket level. Send each packet as it comes in directly to the output. This is nearly 100% transparent (except for IP address and probably the TCP packet sizes). Thought if you want to change or inspect data, you directly need to care for the HTTP yourself, which can be really complicated nowadays (especially due to transfer encoding).

    c) Maybe don’t code yourself, but use an existing proxy (e.g. the Apache webserver or specific proxy programs).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like my Web page http://www.gmarks.org/math_in_e-mail.txt on my Apache 2.2.14 server to display
Basically, what I'm trying to create is a page of div tags, each has
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I'm trying to create an if statement in PHP that prevents a single post
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
I am trying to understand how to use SyndicationItem to display feed which is
I am trying to find ID3V2 tags from MP3 file using jid3lib in Java.
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has

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.