473,387 Members | 1,492 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Request-URI

Hi all,

I am having a problem when trying to use XMLHttpRequest with a proxy
server. The issue is that I want to change the Request-URI from the
header. Here is part of the code:

var url = "http://1.1.1.1:6061";
var host = "2.2.2.2:80";

....
req.open("POST", url, false);
req.setRequestHeader("Host", host);
....
req.send(data);
....

What I want to do is to send this packet to the "url" proxy server,
and have it redirected to the "host" IP and port address. The header
that is being sent is as following:
POST / HTTP/1.1
....
Host: 1.1.1.1
But I want this to be this way:
POST http://2.2.2.2:80/ HTTP/1.1
....
Host: 2.2.2.2

I've tried many ways to do that but with no success:

req.open("POST\x09http://"+host+"/\x09HTTP/1.1", url, false);
req.open("POST\thttp://"+host+"/\tHTTP/1.1", url, false);
req.setRequestHeader("Request-Line","POST http://"+host+"/ HTTP/1.1");
req.setRequestHeader("Method", "POST http://"+host+"/ HTTP/1.1");
Does anyone know a solution to that? If I set my IE proxy to the "url"
address, set the "url" to the "host" address and then initialize the
script then it works, but I don't want to set the proxy.

Thanks,

Rodrigo

Jan 22 '08 #1
1 7519
Rodrigo Brayner wrote:
I am having a problem when trying to use XMLHttpRequest with a proxy
server. The issue is that I want to change the Request-URI from the
header. Here is part of the code:

var url = "http://1.1.1.1:6061";
var host = "2.2.2.2:80";

...
req.open("POST", url, false);
req.setRequestHeader("Host", host);
...
req.send(data);
...

What I want to do is to send this packet to the "url" proxy server,
and have it redirected to the "host" IP and port address. The header
that is being sent is as following:

POST / HTTP/1.1
...
Host: 1.1.1.1

But I want this to be this way:

POST http://2.2.2.2:80/ HTTP/1.1
`:80' would be superfluous here.
...
Host: 2.2.2.2
Tough luck. The `Host' header is set by the HTTP client as obtained from
the request URL which is not part of the request.
I've tried many ways to do that but with no success:
[...]
No surprise here, that is pure fantasy syntax. The first argument of
XHR::open() specifies only the HTTP method, not the HTTP command line.
Does anyone know a solution to that? If I set my IE proxy to the "url"
address, set the "url" to the "host" address and then initialize the
script then it works, but I don't want to set the proxy.
You have to access the HTTP proxy instead of the original server which can
then rewrite the request accordingly. While any Web server that supports
that suffices (such as Apache 1.3+ with the Rewrite* directives and the
`proxy' parameter for the RewriteRule directive), if the proxy server runs
on a different machine, it may be possible to trigger that with a URI; I
have seen e.g. http://http%3A%2F%2Fhost%2F@proxy:6061/ before.
PointedEars
Jan 22 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Jack | last post by:
Hi, I am trying to get a thorough understanding of a code where a addition or deletion of records can be done from a list of records. For addition part of the form, data is being obtained from set...
4
by: SP | last post by:
Hi I have a problem with a customer's XML being submitting to me in a non-well-format XML. They said that there are 18 other partners who has been able to tweak the XML to make it work. So I...
7
by: Shapiro | last post by:
I have a scenario where I log a resquest to a database table and update the request with a corresponding response including the response time. I am using an HttpModule to do this. My challenge...
4
by: Nalaka | last post by:
Hi, I have some request specific data that gets created in a "early event", that I need to pass around to many other events. I need access to this data during that request. (and more importantly...
5
by: dougwig | last post by:
I'm trying to handle the scenario where a user's session times out and and their ajax request triggers a redirection by the webserver (302 error?). I'm using Prototype 1.4 and the my works great...
4
by: Michael Kujawa | last post by:
I am using the following to create an SQL statement using the names and values from request.form. The loop goes through each item in request.form The issue comes in having an additional "and" at...
6
by: santhoskumara | last post by:
How to request to servlet from Ajax and also I got the DOM object in the servlet through Business Logic. Now how will i pass the DOM object from serlvet to Clientside. Where in the client Side i am...
2
by: MDANH2002 | last post by:
Hi From VB.NET I want to simulate the POST request of the following HTML form <html> <title>HTTP Post Testing</title> <body> <form action=http://www.example.com/postdata ...
5
by: chromis | last post by:
Hi there, I've recently been updating a site to use locking on application level variables, and I am trying to use a commonly used method which copies the application struct into the request...
3
by: Joseph Geretz | last post by:
I'm using the Request Filter documentation which can be found here: http://msdn.microsoft.com/en-us/library/system.web.httprequest.filter.aspx In this example, two filters are installed, one...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.