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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T15:04:34+00:00 2026-05-28T15:04:34+00:00

I’m working on a solution to redirect http requests from my browser to another

  • 0

I’m working on a solution to redirect http requests from my browser to another pc.
In a nutshell: Is there a more accurate way to send an incoming HttpListenerRequest as an HttpRequest to a client?

Background: The browser sends http requests to 127.0.0.1:9666 (yes, click’n’load), which should be answered by a download program.
In my case, the download program isn’t running on the machine which runs the browser.
Port Forwarding tools like these don’t work for me: http://www.quantumg.net/portforward.php
So I decided to write a specific click’n’load redirector in C#.
My problem is to redirect the browser’s request. ATM, I listen on 127.0.0.1:9666, send some information to a client, the client redirects this to the downloader program, which answers. (long term short: this is redirected to the browser).
But using pre-defined cases to redirect only the core-information doesn’t seem quite right for me. It should be possible to redirect the whole request. So I don’t need to differ between various cases, and this should be more accurate.
Is there any other way to redirect this request, except from copying all headers and properties?

The Server uses an HttpListener to listen for the browser’s requests.
Then, the server sends an HttpReqest to the Client.
The Client uses an HttpListener to listen for the server’s requests.
The client sends an HttpRequest to the Downloader,
uses GetResponse, and sends this as a response to the server, which responds to the browser.
I’ve looked up some functions in the MSDN, but didn’t find a good way to “copy a whole request”.

So here is my problem code:

Thread.Sleep(1500);
//Read client's/JDownloader's stream, send to browser/redirector
do
{
    Read = Outstream.Read(Buffer, 0, Buffer.Length);
    Totalr += Read;
    Instream.Write(Buffer, 0, Read);
    Sent += Read;
    // Bufferstr += ASCIIEncoding.ASCII.GetString(Buffer, 0, Read); debugging
} while (Read != 0);

Without the Thread.Sleep, the first read returns 171 bytes were read (just and exactly the HTTP header, buffer-length is 1024bytes).
second iteration: when executing Outstream.Read, nothing happens. No matter how long I wait. It seems, the reader is waiting for traffic to receive, but there is no traffic to receive (weird…) When the thread sleeps for 500-1500ms, the first read returns 351bytes were read (the complete http request), and then again, second iteration, nothing.
This happens when reading from the browser’s or JDownloader’s NetworkStream. They never return 0. A dirty method to get this working is to replace the while-argument with Read == Buffer.Length, dirty because it will fail when exactly Buffer.Length bytes are received (endless waiting again, yay).
The DataAvailable property also dosn’t always seem to be right, sometimes it is set to false, when the program didn’t even read something from the stream, but there were bytes to receive.(also weird…)
Any other ideas for proper receiving loops?


Nobody? short summary of my problem: neither the browser’s request stream, nor JDownloaders response stream return 0. When attempting another read, the program just waits for more bytes to receive.
So I don’t know a failsafe method to read the entire stream.
Just repeating until the amount of bytes read is lower than the buffer’s length will result in previously mentioned endless wait for bytes, when streamlength % bufferlength == 0.

Also, it seems JDownloader needs more time to generate an answer and write it into the stream than my program attempts to read the stream. So I will only receive a part of the stream. Another read attempt will result in, hooray, an endless wait for bytes.
Is there another way to receive the whole stream without a static delay (via thread sleep)?

  • 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-05-28T15:04:35+00:00Added an answer on May 28, 2026 at 3:04 pm

    Can you just open a TcpListener and forward the raw bytes? That way you do not need to concern yourself with HTTP at all.

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I am currently running into a problem where an element is coming back from
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have a text area in my form which accepts all possible characters from
Does anyone know how can I replace this 2 symbol below from the string
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I am writing an app with both english and french support. The app requests
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function

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.