I'm aware of the webRequest experimental API supported by Chromium.
AFAIU, it only lets me modify the HTTP request headers, and not
request parameters. What I wanted to do is something like intercept a
GET/POST request, store it locally, and maybe retry it if fails with
altered parameters. Is there anyway that I can do that in Chromium?
Thanks.
--
Jeenu
What parameters do you want to modify?
Are you referring to the query strings? ("?foo=bar&baz" in
"http://example.org/?foo=bar&baz", for example)? In that case, you can
use onBeforeRequest to store the original url, redirect to your modified
url (or vice versa), and use onCompleted with the given requestid to
check whether it was successfully completed.
onBeforeSendHeaders should work as usual/expected when redirecting.
I'm not sure if you can modify POST requests in the same way as
above--you may need to use onBeforeSendHeaders, and I don't know if that
header is available. Neither am I sure how you would retry; I guess it'd
depend on how the request was made, if it's possible at all.
Both of those mean the same thing. XD
What I meant to ask was, do you want to:
A: Alter the parameters if the request fails, then retry with altered
parameters, or
B: Store the original parameters, request with altered parameters, then
retry with original if the request fails.
For those of us who find pseudo-code clearer:
C: params = [a,b,c]; request(params); if (fail()) request([b,a,c]); //A
D: params = [a,b,c]; request([b,a,c]); if (fail()) request(params); //B
I'd say I wanted to do A. But despite the order I want to do/store
things, what I essentially want to do is to manipulate the request.
> Are you referring to the query strings? ("?foo=bar&baz" in
> "http://example.org/?foo=bar&baz", for example)? In that case, you can
> use onBeforeRequest to store the original url, redirect to your modified
> url (or vice versa), and use onCompleted with the given requestid to
> check whether it was successfully completed.
Yes, I suppose that's what I would now do with GET requests.
> I'm not sure if you can modify POST requests in the same way as
> above--you may need to use onBeforeSendHeaders, and I don't know if that
> header is available. Neither am I sure how you would retry; I guess it'd
> depend on how the request was made, if it's possible at all.
I'm more interested in retrying POST requests, which is what I'm not
clear about. The API page doesn't mention about exposing any of the
POST request parameters to any of the callbacks. Nor does it mention
so about GET requests, but in that case URL is enough for us.
I didn't quite get to what you mean by the 'how the request was made'.
Did you mean the encoding scheme for the POST request? Assuming I've a
way to know that beforehand, do you see anyway to manipulate POST
request parameters?
Thanks.
--
Jeenu
On Sun, 2011-11-27 at 22:15 +0530, Jeenu V wrote:
> On Sun, Nov 27, 2011 at 2:29 PM, Ben <benj...@gmail.com> wrote:
> > What I meant to ask was, do you want to:
> > A: Alter the parameters if the request fails, then retry with altered
> > parameters, or
> >
> > For those of us who find pseudo-code clearer:
> > C: params = [a,b,c]; request(params); if (fail()) request([b,a,c]); //A
>
> I'd say I wanted to do A. But despite the order I want to do/store
> things, what I essentially want to do is to manipulate the request.
>
> > Are you referring to the query strings? ("?foo=bar&baz" in
> > "http://example.org/?foo=bar&baz", for example)? In that case, you can
> > use onBeforeRequest to store the original url, redirect to your modified
> > url (or vice versa), and use onCompleted with the given requestid to
> > check whether it was successfully completed.
>
> Yes, I suppose that's what I would now do with GET requests.
>
> > I'm not sure if you can modify POST requests in the same way as
> > above--you may need to use onBeforeSendHeaders, and I don't know if that
> > header is available. Neither am I sure how you would retry; I guess it'd
> > depend on how the request was made, if it's possible at all.
>
> I'm more interested in retrying POST requests, which is what I'm not
> clear about. The API page doesn't mention about exposing any of the
> POST request parameters to any of the callbacks. Nor does it mention
> so about GET requests, but in that case URL is enough for us.
Yeah, from what I can tell there's no way to modify parameters of a GET
request other than to change the url. And according to [0], they
currently don't allow you to modify the "content-length" header, so they
likely don't allow you to change POST parameters either. You can file a
feature request on http://new.crbug.com/
> I didn't quite get to what you mean by the 'how the request was made'.
> Did you mean the encoding scheme for the POST request? Assuming I've a
> way to know that beforehand, do you see anyway to manipulate POST
> request parameters?
Basically, what I meant was you probably would need to know whether the
request came from a tab, or an iframe, or some other element on a page
(and which tab that page/element is on). Of course you wouldn't need to
know that if there was some extension api that allowed you to retry a
request, but without one I would imagine it'd be pretty cumbersome.
>
> Thanks.
>
No problem, glad to help. ^_^
> --
> Jeenu
>
[0]http://code.google.com/chrome/extensions/experimental.webRequest.html#life_cycle_footnote
On Sun, Nov 27, 2011 at 2:29 PM, Ben <benj...@gmail.com> wrote:I'd say I wanted to do A. But despite the order I want to do/store
> What I meant to ask was, do you want to:
> A: Alter the parameters if the request fails, then retry with altered
> parameters, or
>
> B: Store the original parameters, request with altered parameters, then
> retry with original if the request fails.
>
> For those of us who find pseudo-code clearer:
> C: params = [a,b,c]; request(params); if (fail()) request([b,a,c]); //A
> D: params = [a,b,c]; request([b,a,c]); if (fail()) request(params); //B
things, what I essentially want to do is to manipulate the request.