Nodegit 克隆导致“No Content-Type header in response”错误
Nodegit clone causes “No Content-Type header in response” error
我在 CentOS 6.7 上遇到节点git 的问题。在我们的 Windows 开发环境中,我可以使用 nodegit 远程 clone/push/pull。
然而,在 CentOS 上,我在克隆时遇到以下错误:
No Content-Type header in response
我们不使用 Apache,只使用标准的 GitLab rpm。 GitLab 在 CentOS 机器上也运行良好 - 我能够从 Git Bash 成功拉取和推送。不幸的是,我需要通过 nodegit 以编程方式执行此操作,但它不起作用。
如果可能的话,我宁愿不必求助于 CURL - nodegit 对于我的项目来说确实是一个更有尊严的选择。
请注意,我在 Gitlab 实例上使用基本 HTTP user/password 进行授权,因为:
- gitlab 和所有编程 git 东西都隐藏在服务器端,
- 这是一个概念验证,用于查看 nodegit/gitlab 解决方案是否可行。
这是尝试克隆的函数 - 它在 Windows:
上运行良好
function pushUserUpdatesToGit(req, res, user, myItem, localPath) {
var repo, index, oid, remote,
userCreds = {
credentials: function() {
return nodegit.Cred.userpassPlaintextNew(user.username, user.pwd);
}
},
authStuff = {
remoteCallbacks: {
credentials: userCreds.credentials,
certificateCheck: function() { return 1; }
}
};
return nodegit.Clone.clone(myItem.GitLabRepoPath, localPath, authStuff)
.then(function(theRepo) {
repo = theRepo; // save it to reference in any callback we feel like
}, function (err) {
console.log("Error cloning repo: " + err );
return handleError(res, err);
}
).then(function() {
return repo.openIndex();
}, function (err) {
return handleError(res, err);
})
// Some exciting stuff happens in here that I won't bore you all with
.catch(function(error) {
console.log("ERROR DOING GIT STUFF: " + error);
return handleError(res, error);
}).done(function() {
console.log("done with git stuff");
return res.json(200, myItem);
});
}
您收到此错误消息似乎是因为您的 git 服务器响应不支持智能 HTTP (https://git-scm.com/book/en/v2/Git-on-the-Server-Smart-HTTP)。
默认情况下,gitlab 的 nginx 配置支持此功能。你有没有机会 运行 gitlab 的包含的 nginx 设置在反向代理后面?
如果没有,并且您没有使用 gitlab 中包含的 nginx 设置,这可能会有所帮助:https://gist.github.com/massar/9399764
我在 CentOS 6.7 上遇到节点git 的问题。在我们的 Windows 开发环境中,我可以使用 nodegit 远程 clone/push/pull。
然而,在 CentOS 上,我在克隆时遇到以下错误:
No Content-Type header in response
我们不使用 Apache,只使用标准的 GitLab rpm。 GitLab 在 CentOS 机器上也运行良好 - 我能够从 Git Bash 成功拉取和推送。不幸的是,我需要通过 nodegit 以编程方式执行此操作,但它不起作用。
如果可能的话,我宁愿不必求助于 CURL - nodegit 对于我的项目来说确实是一个更有尊严的选择。
请注意,我在 Gitlab 实例上使用基本 HTTP user/password 进行授权,因为:
- gitlab 和所有编程 git 东西都隐藏在服务器端,
- 这是一个概念验证,用于查看 nodegit/gitlab 解决方案是否可行。
这是尝试克隆的函数 - 它在 Windows:
上运行良好function pushUserUpdatesToGit(req, res, user, myItem, localPath) {
var repo, index, oid, remote,
userCreds = {
credentials: function() {
return nodegit.Cred.userpassPlaintextNew(user.username, user.pwd);
}
},
authStuff = {
remoteCallbacks: {
credentials: userCreds.credentials,
certificateCheck: function() { return 1; }
}
};
return nodegit.Clone.clone(myItem.GitLabRepoPath, localPath, authStuff)
.then(function(theRepo) {
repo = theRepo; // save it to reference in any callback we feel like
}, function (err) {
console.log("Error cloning repo: " + err );
return handleError(res, err);
}
).then(function() {
return repo.openIndex();
}, function (err) {
return handleError(res, err);
})
// Some exciting stuff happens in here that I won't bore you all with
.catch(function(error) {
console.log("ERROR DOING GIT STUFF: " + error);
return handleError(res, error);
}).done(function() {
console.log("done with git stuff");
return res.json(200, myItem);
});
}
您收到此错误消息似乎是因为您的 git 服务器响应不支持智能 HTTP (https://git-scm.com/book/en/v2/Git-on-the-Server-Smart-HTTP)。
默认情况下,gitlab 的 nginx 配置支持此功能。你有没有机会 运行 gitlab 的包含的 nginx 设置在反向代理后面?
如果没有,并且您没有使用 gitlab 中包含的 nginx 设置,这可能会有所帮助:https://gist.github.com/massar/9399764