-
Notifications
You must be signed in to change notification settings - Fork 96
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
What if the server response timeOut or 404 #65
Comments
You can check |
I'm not getting any statusCode..... is their a timeOut setting to make it shorter. Or why am I not getting the statusCode ? function responseInterceptor(request, response) {
console.log('+++++++++++++++++++ Response ++++++++++++++++++++');
console.log(arguments, response.statusCode); // < === Not getting 404 nor timeOut
console.log('+++++++++++++++++++++++++++++++++++++++++++++++++');
}
function requestInterceptor(request, response) {
// .........
}
function attachInterceptors() {
proxy.intercept({
phase: 'request',
as: 'json'
}, requestInterceptor);
proxy.intercept({
phase: 'response',
as: 'json'
}, responseInterceptor);
}
proxy = hoxy.createServer({
reverse: 'https://example.com/'
// tls: {
// key: fs.readFileSync('./my-server.key.pem'),
// cert: fs.readFileSync('./my-server.crt.pem')
// }
}).listen(5000);
attachInterceptors(); |
Is it logging |
'1':
Response {
domain: null,
_events: { log: [Function] },
_eventsCount: 1,
_maxListeners: undefined,
_data: { statusCode: 200, headers: {}, slow: {} },
phase: 'request' },
'2':
Cycle {
domain: null,
_events: { log: [Function] },
_eventsCount: 1,
_maxListeners: undefined,
_proxy:
Proxy {
domain: null,
_events: {},
_eventsCount: 0,
_maxListeners: undefined,
_reverse: 'https://non-existing-example.com/',
_tls: undefined,
_intercepts: [Object],
_server: [Object] },
_request:
Request {
domain: null,
_events: [Object],
_eventsCount: 1,
_maxListeners: undefined,
_data: [Object],
_populated: true,
phase: 'request' },
_response:
Response {
domain: null,
_events: [Object],
_eventsCount: 1,
_maxListeners: undefined,
_data: [Object],
phase: 'request' },
_phase: 'request' } } |
That looks incomplete. What does it log if you just do |
Nothing is been logged. I've managed to resolve this issues by login in the 'response-sent' phase. Yeah, I've trim the request part of the argument cause I didn't tough it was usefull. So if you intend to support the response.statusCode on But if you intend no to support it, and instead encorage user to use the I would be more than happy to help you either ways, I think hoxy is amazing ;) !!! And you're very kind ^^ |
But specifically, when you say nothing was logged, do you mean it logged |
console.log() never reached, as if the timeOut is way to big, or something like that |
The output pasted above looks like a fragment of |
So no logging the server's timeOut (waited my whole lunch, so about an hour or so ) This is my code#!/usr/bin/env node
/*eslint no-unused-vars: 0*/
'use strict';
(function () {
var hoxy = require('hoxy'), proxy;
function responseSentInterceptor(request, response) {
console.log('====================== RESPONSE SENT INTERCEPTOR');
console.log(request, response);
}
function responseInterceptor(request, response) {
console.log('====================== RESPONSE INTERCEPTOR');
console.log(request, response);
}
function requestInterceptor(request, response) {
console.log('======================= REQUEST INTERCEPTOR');
console.log(request, response);
}
function attachInterceptors() {
proxy.intercept({
phase: 'request',
as: 'json'
}, requestInterceptor);
proxy.intercept({
phase: 'response',
as: 'json'
}, responseInterceptor);
proxy.intercept({
phase: 'response-sent'
}, responseSentInterceptor);
}
proxy = hoxy.createServer({
reverse: 'http://thisIsNot.a.real.server'
}).listen(5000);
attachInterceptors();
}()); Output
|
So I hope this clarify my issue =^.^= And thanks again !! (: |
Can you add proxy.log('error warn debug', process.stderr);
proxy.log('info', process.stdout); and let me know if it logs any errors or anything? |
How to control the server timeOut or statusCode === 404 in the 'response' phase ??
The text was updated successfully, but these errors were encountered: