[英]Nodegit clone causes “No Content-Type header in response” error
我在CentOS 6.7上的nodegit遇到問題。 在我們的Windows開發環境中,我可以使用nodegit從遠程克隆/推送/拉取。
但是,在CentOS上,克隆時出現以下錯誤:
沒有響應的Content-Type標頭
我們不使用Apache,而是使用標准的GitLab rpm。 GitLab在CentOS盒上也運行良好-我能夠從Git Bash成功拉出和推入。 不幸的是,我需要通過nodegit以編程方式執行此操作,並且它無法正常工作。
如果可能的話,我寧願不必求助於CURL-對於我的項目,nodegit確實看起來像是一個更為端庄的選擇。
應該注意的是,我在Gitlab實例上使用基本的HTTP用戶/密碼進行授權,因為:
這是嘗試克隆的函數-在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服務器響應不支持Smart 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
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.