By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,917 Members | 1,305 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,917 IT Pros & Developers. It's quick & easy.

Request-URI

P: n/a
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
Share this Question
Share on Google+
1 Reply


P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.