ci & admin & auth & cli
This commit is contained in:
parent
981f3209e0
commit
5cb35f54d5
12 changed files with 143 additions and 34 deletions
|
|
@ -7,11 +7,12 @@ using Newtonsoft.Json;
|
|||
|
||||
namespace nuget_cli
|
||||
{
|
||||
public class nugetdresp {
|
||||
public int ecode {get; set; }
|
||||
public string message {get; set; }
|
||||
public string id { get; set; }
|
||||
}
|
||||
public class nugetdresp
|
||||
{
|
||||
public int ecode { get; set; }
|
||||
public string message { get; set; }
|
||||
public string id { get; set; }
|
||||
}
|
||||
public class UploadFilesToServerUsingWebRequest
|
||||
{
|
||||
|
||||
|
|
@ -41,7 +42,7 @@ namespace nuget_cli
|
|||
httpWebRequest.AllowAutoRedirect = false;
|
||||
httpWebRequest.Headers.Add("X-NuGet-Client-Version", Constants.ClientVersion);
|
||||
httpWebRequest.Headers.Add("X-NuGet-ApiKey", apikey);
|
||||
httpWebRequest.ContentLength = boundarybytes.Length +
|
||||
httpWebRequest.ContentLength = boundarybytes.Length +
|
||||
fileheaderbytes.Length + fi.Length + endBoundaryBytes.Length;
|
||||
|
||||
|
||||
|
|
@ -68,7 +69,7 @@ namespace nuget_cli
|
|||
requestStream.Write(endBoundaryBytes, 0, endBoundaryBytes.Length);
|
||||
requestStream.Close();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
catch (Exception rex)
|
||||
{
|
||||
|
|
@ -82,24 +83,24 @@ namespace nuget_cli
|
|||
}, httpWebRequest);
|
||||
|
||||
WebResponse resp = httpWebRequest.GetResponse();
|
||||
|
||||
|
||||
Stream stream = resp.GetResponseStream();
|
||||
StreamReader re = new StreamReader(stream);
|
||||
if (resp is HttpWebResponse)
|
||||
{
|
||||
String json = re.ReadToEnd();
|
||||
report.Message = json;
|
||||
String json = re.ReadToEnd();
|
||||
report.Message = json;
|
||||
|
||||
var res = JsonConvert.DeserializeObject<nugetdresp>(json);
|
||||
report.AlreadyPresent = res.ecode == 1;
|
||||
var res = JsonConvert.DeserializeObject<nugetdresp>(json);
|
||||
report.AlreadyPresent = res.ecode == 1;
|
||||
|
||||
var hrep = resp as HttpWebResponse;
|
||||
report.StatusCode = hrep.StatusCode.ToString();
|
||||
// ecode == 1 => package already present server side.
|
||||
report.OK = hrep.StatusCode ==
|
||||
HttpStatusCode.Accepted
|
||||
|| hrep.StatusCode == HttpStatusCode.OK
|
||||
|| res.ecode == 1;
|
||||
var hrep = resp as HttpWebResponse;
|
||||
report.StatusCode = hrep.StatusCode.ToString();
|
||||
// ecode == 1 => package already present server side.
|
||||
report.AlreadyPresent = res.ecode == 1;
|
||||
report.OK = hrep.StatusCode == HttpStatusCode.Accepted
|
||||
|| hrep.StatusCode == HttpStatusCode.OK
|
||||
|| report.AlreadyPresent;
|
||||
}
|
||||
else throw new Exception("Invalid server response type");
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue