Request-URI

R

Rodrigo Brayner

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
 
T

Thomas 'PointedEars' Lahn

Rodrigo said:
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::eek:pen() 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://host/@proxy:6061/ before.


PointedEars
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,430
Messages
2,571,676
Members
48,796
Latest member
Greg L.

Latest Threads

Top