-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Async callback? #2
Comments
not me, it's fork of other unmaintained repo.I'm just support and fix some bugs add add features.
you are right and not at the same time:) If you want just operate over uri or|and headers and not affect on http content you can really simple use async function. On the other hand, scanning http content are really synchronous:( Thanks for this issues, I'll add callback only for this case(scanning all http content).
Keep calm and use async functions:) server.request(whitelist, analyzeRequest);
function allowRequest(icapReq, icapRes, req, res) {
// see examples/example.js, acceptRequest
// ..
}
function disallowrequest(icapReq, icapRes, req, res) {
// see examples/example.js, rejectRequest
// ..
}
function analyzeRequest(icapReq, icapRes, req, res) {
makeDbQuery(req.uri, req.headers, (err, answer) => {
if (err) {
return allowRequest();
}
if (answer) {
return allowRequest();
} else {
return disallowRequest();
}
})
} Just try test to scan with async functions and if you have a troubles, please, tell |
I am having some trouble with multiple middleware, in theory this should work:
And when testing I get this in my logs:
But after this, the request gets 'stuck'. I put a log statement in acceptRequest and it seems it never gets called. Any idea what the issue could be? It has the same problem with:
I am using node v4.2.6 |
Figured it out.... The middleware is a bit different to express (where you can chain by simply passing multiple function inputs). Here you need one line per middleware. So the example becomes:
Works well :-) |
Hi there, Sorry to bother you, but I have another question.... I'm attempting to just send a simple error page back on any rejection responses. My idea is to stop processing immediately (don't even request more preview), because I would like to return the response as fast as possible. It doesn't seem to be working. It never actually returns the data back to the client. Any idea of the issue? Here is my code:
|
@hongkongkiwi |
It's unfortunately not working.... Here is my full script. When I use this, it doesn't come back with the response :-(
Here is my test script, it's very simple. And here is my squid.conf example. I think it's straightforward but just in case. Unfortunately it doesn't work, it simply doesn't give an answer back to the test script. Squid thinks it's having an error, so it's not returning something correctly. |
First, please add var url = require('url');
and for respmod
Other, do you really need respmod? You wrote that you are checking only url, maybe reqmod is better solution to check url? I create a gitter channel. Please, let's talk there in. |
And add |
First of all, thank you so much for making this!! It's really fantastic and you've totally taken the pain out of writing an icap server.
I'm facing a bit of an issue and it might seem simple to you so any help is appreciated.
Essentially I want to scan incoming requests for the uri (done this), then use that uri to do a blacklist lookup or scanning from a db. The db callback is asynchronous so that means I don't know when it's going to come back.
How could I integrate this into your model? It seems that processing icap requests is synchronous. Essentially I am happy to keep receiving data, but at some point I want come back and say yes finally this is allowed, or finally this is not allowed.
Any quick examples?
The text was updated successfully, but these errors were encountered: