// non-javadoc, see interface HttpResponse public virtual void SetStatusLine(StatusLine statusline) { this.statusline = Args.NotNull(statusline, "Status line"); this.ver = statusline.GetProtocolVersion(); this.code = statusline.GetStatusCode(); this.reasonPhrase = statusline.GetReasonPhrase(); }
public override void Run() { HttpClient httpclient = new DefaultHttpClient(); HttpResponse response; string responseString = null; try { response = httpclient.Execute(new HttpGet(pathToDoc.ToExternalForm())); StatusLine statusLine = response.GetStatusLine(); Log.D(ReplicationTest.Tag, "statusLine " + statusLine); NUnit.Framework.Assert.AreEqual(HttpStatus.ScNotFound, statusLine.GetStatusCode() ); } catch (ClientProtocolException e) { NUnit.Framework.Assert.IsNull("Got ClientProtocolException: " + e.GetLocalizedMessage (), e); } catch (IOException e) { NUnit.Framework.Assert.IsNull("Got IOException: " + e.GetLocalizedMessage(), e); } finally { httpRequestDoneSignal.CountDown(); } }
// non-javadoc, see interface HttpResponseFactory public virtual HttpResponse NewHttpResponse(StatusLine statusline, HttpContext context ) { Args.NotNull(statusline, "Status line"); return(new BasicHttpResponse(statusline, this.reasonCatalog, DetermineLocale(context ))); }
public static async Task <string> ToHttpStringAsync(this HttpResponseMessage me) { var startLine = new StatusLine(new HttpProtocol($"HTTP/{me.Version.Major}.{me.Version.Minor}"), me.StatusCode).ToString(); var headers = ""; if (me.Headers.NotNullAndNotEmpty()) { var headerSection = HeaderSection.CreateNew(me.Headers); headers += headerSection.ToString(endWithTwoCRLF: false); } var messageBody = ""; if (!(me.Content is null)) { if (me.Content.Headers.NotNullAndNotEmpty()) { var headerSection = HeaderSection.CreateNew(me.Content.Headers); headers += headerSection.ToString(endWithTwoCRLF: false); } messageBody = await me.Content.ReadAsStringAsync(); } return(startLine + headers + CRLF + messageBody); }
public static void Load() { GameData.GameMusic = GameData.SoundFactory.CreateMusic(); GameData.GameMusic.Play(); GameData.CurrentScreen = GameData.Screens.StartScreen; StatusLine.Load(5, 5); }
public static async Task <string> ToHttpStringAsync(this HttpResponseMessage me) { var startLine = new StatusLine(new HttpProtocol($"HTTP/{me.Version.Major}.{me.Version.Minor}"), me.StatusCode).ToString(); string headers = ""; if (me.Headers != null && me.Headers.Count() != 0) { var headerSection = HeaderSection.CreateNew(me.Headers); headers += headerSection.ToString(endWithTwoCRLF: false); } string messageBody = ""; if (me.Content != null) { if (me.Content.Headers != null && me.Content.Headers.Count() != 0) { var headerSection = HeaderSection.CreateNew(me.Content.Headers); headers += headerSection.ToString(endWithTwoCRLF: false); } messageBody = await me.Content.ReadAsStringAsync().ConfigureAwait(false); } return(startLine + headers + CRLF + messageBody); }
protected override void HandleGit(Repository repo, string directory, string relativeDir, string repoUrl) { PrintLine($"{Cyan}{relativeDir}"); ProgressBar fetchProgress = null; ProgressBar checkoutProgress = null; StatusLine checkoutStatus = null; var signature = repo.Config.BuildSignature(DateTimeOffset.UtcNow); var options = new PullOptions { FetchOptions = new FetchOptions { CredentialsProvider = CredentialProvider.Provide, OnTransferProgress = progress => { if (fetchProgress is null) { fetchProgress = ProgressBar(new ProgressBarSpec { MaxValue = progress.TotalObjects, Format = " Fetching: [<<bar>>] <<percentage>> (<<value>>/<<max>>)" }, style: ProgressBarStyle.Lines); } fetchProgress.Value = progress.ReceivedObjects * 100; return(true); } },
// non-javadoc, see interface HttpResponse public virtual void SetStatusCode(int code) { Args.NotNegative(code, "Status code"); this.statusline = null; this.code = code; this.reasonPhrase = null; }
public override void Run() { HttpClient httpclient = new DefaultHttpClient(); HttpResponse response; string responseString = null; try { HttpPut post = new HttpPut(pathToDoc1.ToExternalForm()); StringEntity se = new StringEntity(docJson.ToString()); se.SetContentType(new BasicHeader("content_type", "application/json")); post.SetEntity(se); response = httpclient.Execute(post); StatusLine statusLine = response.GetStatusLine(); Log.D(Test7_PullReplication.Tag, "Got response: " + statusLine); NUnit.Framework.Assert.IsTrue(statusLine.GetStatusCode() == HttpStatus.ScCreated); } catch (ClientProtocolException e) { NUnit.Framework.Assert.IsNull("Got ClientProtocolException: " + e.GetLocalizedMessage (), e); } catch (IOException e) { NUnit.Framework.Assert.IsNull("Got IOException: " + e.GetLocalizedMessage(), e); } httpRequestDoneSignal.CountDown(); }
// non-javadoc, see interface HttpResponse public virtual void SetStatusLine(ProtocolVersion ver, int code, string reason) { Args.NotNegative(code, "Status code"); this.statusline = null; this.ver = ver; this.code = code; this.reasonPhrase = reason; }
public Item GetBounty() { active = false; var item = ItemsList.GetItemByLvl(Game.maxDungeonLevel + (Game.player.perksSystem.CheckPerk(PerksList.luckPerk) ? 2 : 0)); StatusLine.AddLine(" " + " You got in the chest: " + item.name); return(item); }
public override byte[] GetHeader(params HttpHeader[] rewrites) { sb.Clear(); sb.Append(StatusLine.ToString()); HeaderList.Format(sb, rewrites); sb.Append("\r\n"); return(Encoding.GetBytes(sb.ToString())); }
private void Initialize(HttpMethod method) { Method = method; StatusLine.Clear(); HeaderList.Clear(); MessageBody = null; c = TextStore.ReadChar(); }
/// <summary>Creates a response from a status line.</summary> /// <remarks> /// Creates a response from a status line. /// The response will not have a reason phrase catalog and /// use the system default locale. /// </remarks> /// <param name="statusline">the status line</param> public BasicHttpResponse(StatusLine statusline) : base() { this.statusline = Args.NotNull(statusline, "Status line"); this.ver = statusline.GetProtocolVersion(); this.code = statusline.GetStatusCode(); this.reasonPhrase = statusline.GetReasonPhrase(); this.reasonCatalog = null; this.locale = null; }
public void ToStringTest(int statusCode, string protocol, string version, string result) { var instance = new StatusLine { StatusCode = statusCode, Protocol = protocol, Version = version }; Assert.Equal(instance.ToString(), result); Assert.Equal($"{instance}", result); }
public void Invalid(int statusCode, string protocol, string version) { var instance = new StatusLine { StatusCode = statusCode, Protocol = protocol, Version = version }; Assert.False(instance.Valid); Assert.Throws <InvalidOperationException>(() => instance.Validate()); }
public void Valid(int statusCode, string protocol, string version) { var instance = new StatusLine { StatusCode = statusCode, Protocol = protocol, Version = version }; Assert.True(instance.Valid); Assert.True(instance.Validate() != null); }
protected override void InitUserButtons(FriendButtonsUI buttons) { EnableAcceptFriendshipButton(() => StatusLine.EnableRequestAcceptedMessage()); EnableDeclineFriendshipButton(() => { UserButtons.DisableAddFriendButton(); StatusLine.EnableRequestDeclinedMessage(); }); }
// non-javadoc, see interface LineFormatter public virtual CharArrayBuffer FormatStatusLine(CharArrayBuffer buffer, StatusLine statline) { Args.NotNull(statline, "Status line"); CharArrayBuffer result = InitBuffer(buffer); DoFormatStatusLine(result, statline); return(result); }
// non-javadoc, see interface HttpResponse public virtual StatusLine GetStatusLine() { if (this.statusline == null) { this.statusline = new BasicStatusLine(this.ver != null ? this.ver : HttpVersion.Http11 , this.code, this.reasonPhrase != null ? this.reasonPhrase : GetReason(this.code )); } return(this.statusline); }
public virtual void InitStatusLine() { Rect R = GetExtent(); R.A.Y = R.B.Y - 1; StatusLine = new StatusLine(R, StatusLine.NewStatusDef(0, 0xFFFF, StatusLine.NewStatusKey("~Alt-X~ Exit", KeyboardKeys.AltX, cmQuit, StdStatusKeys(null)), null)); }
/// <summary>Creates a response from elements of a status line.</summary> /// <remarks> /// Creates a response from elements of a status line. /// The response will not have a reason phrase catalog and /// use the system default locale. /// </remarks> /// <param name="ver">the protocol version of the response</param> /// <param name="code">the status code of the response</param> /// <param name="reason"> /// the reason phrase to the status code, or /// <code>null</code> /// </param> public BasicHttpResponse(ProtocolVersion ver, int code, string reason) : base() { Args.NotNegative(code, "Status code"); this.statusline = null; this.ver = ver; this.code = code; this.reasonPhrase = reason; this.reasonCatalog = null; this.locale = null; }
/// <summary>Creates a new response.</summary> /// <remarks> /// Creates a new response. /// This is the constructor to which all others map. /// </remarks> /// <param name="statusline">the status line</param> /// <param name="catalog"> /// the reason phrase catalog, or /// <code>null</code> to disable automatic /// reason phrase lookup /// </param> /// <param name="locale"> /// the locale for looking up reason phrases, or /// <code>null</code> for the system locale /// </param> public BasicHttpResponse(StatusLine statusline, ReasonPhraseCatalog catalog, CultureInfo locale) : base() { this.statusline = Args.NotNull(statusline, "Status line"); this.ver = statusline.GetProtocolVersion(); this.code = statusline.GetStatusCode(); this.reasonPhrase = statusline.GetReasonPhrase(); this.reasonCatalog = catalog; this.locale = locale; }
public void CheckInformant(int i, int j) { if ((i < Game.world.height) && (j < Game.world.width)) { if (Game.world.map[i, j] == 'I') { StatusLine.ShowInfo(); } } }
public static bool IsTransientError(StatusLine status) { // TODO: in ios implementation, it considers others errors int code = status.GetStatusCode(); if (code == 500 || code == 502 || code == 503 || code == 504) { return true; } return false; }
public static bool IsTransientError(StatusLine status) { // TODO: in ios implementation, it considers others errors int code = status.GetStatusCode(); if (code == 500 || code == 502 || code == 503 || code == 504) { return(true); } return(false); }
/// <summary> /// Returns the response body as a String if the response was successful (a /// 2xx status code). /// </summary> /// <remarks> /// Returns the response body as a String if the response was successful (a /// 2xx status code). If no response body exists, this returns null. If the /// response was unsuccessful (>= 300 status code), throws an /// <see cref="Apache.Http.Client.HttpResponseException">Apache.Http.Client.HttpResponseException /// </see> /// . /// </remarks> /// <exception cref="Apache.Http.Client.HttpResponseException"></exception> /// <exception cref="System.IO.IOException"></exception> public virtual string HandleResponse(HttpResponse response) { StatusLine statusLine = response.GetStatusLine(); HttpEntity entity = response.GetEntity(); if (statusLine.GetStatusCode() >= 300) { EntityUtils.Consume(entity); throw new HttpResponseException(statusLine.GetStatusCode(), statusLine.GetReasonPhrase ()); } return(entity == null ? null : EntityUtils.ToString(entity)); }
public void Attack(Persona persona) { StatusLine.AddLine(" " + name + " attack " + persona.name); persona.ReceiveAttack(attack, this); if (this is Player) { if (Game.player.perksSystem.CheckPerk(PerksList.doubleAttackPerk) && (persona.helth > 0)) { StatusLine.AddLine(" " + Game.player.name + " do double attack"); persona.ReceiveAttack(attack, this); } } }
private void ParseFile() { int SS_nombres = 0; string SS_temps = ""; string SS_titre = ""; StatusLine ligne = StatusLine.NLine; allCCF = new List <CCF>(); foreach (string Base in allLineOfFile) ///instruction qui va execute l'element des sous-titres avec la recuperation d'une chaine de characteres qui sont ici les sous-titres { if (Base == "") { ligne = StatusLine.EmptyLine; } switch (ligne) { case StatusLine.NLine: SS_nombres = Int32.Parse(Base); ligne++; break; case StatusLine.TimerLine: SS_temps = Base; ligne++; break; case StatusLine.STLine: SS_titre += Base + "\n"; break; case StatusLine.EmptyLine: CCF CCs = new CCF(SS_nombres, SS_temps, SS_titre); if (!allCCF.Contains(CCs)) { allCCF.Add(CCs); } ligne = StatusLine.NLine; SS_titre = ""; break; } } CCF CCfin = new CCF(SS_nombres, SS_temps, SS_titre); if (!allCCF.Contains(CCfin)) { allCCF.Add(CCfin); } }
//Le parseFile va permettre d'analyser le fichier et ainsi nous permettre de filtrer les information a afficher private void file()// on boucle le fichier pour un bloc cad : Line , Temps et et le sous titre mais une fois qu'on a une ligne vide ducoup on stock ce premier bloc pour reinitialiser tout les objet pour stocker le bloc suivant { int nbSub = -1; string Timer = ""; string Subs = ""; StatusLine statusL = StatusLine.line; allSub = new List <SousTitre>(); foreach (string line in LineOfFile) { if (line == "") { statusL = StatusLine.emptyLine; } switch (statusL) { case StatusLine.line: nbSub = Int32.Parse(line); statusL++; break; case StatusLine.timeline: Timer = line; statusL++; break; case StatusLine.srtline: Subs += line + "\n"; break; case StatusLine.emptyLine: SousTitre sub = new SousTitre(nbSub, Timer, Subs); if (!allSub.Contains(sub)) { allSub.Add(sub); } statusL = StatusLine.line; Subs = ""; break; } } SousTitre srtend = new SousTitre(nbSub, Timer, Subs);//quand on arrive au dernier bloc du doc srt il n'y a pas de ligne vide ducoup on doit le stocker en fin de boucle if (!allSub.Contains(srtend)) { allSub.Add(srtend); } }// Alors on a stocker toutes les information des sous-titre dans la classe "Sous-Titre"
/// <summary> /// Initialize new SIP response. /// </summary> /// <param name="sipRequest">SIP request from which SIP response will be created.</param> /// <param name="statusCode">SIP response status code.</param> /// <returns>SIP response message.</returns> public static SipResponse GetResponse(this SipRequest sipRequest, StatusCode statusCode) { StatusLine sl = new StatusLine(statusCode); SipResponse response = new SipResponse(sl); // required response headers response.Headers.From = sipRequest.Headers.From; response.Headers.CallId = sipRequest.Headers.CallId; response.Headers.CSeq = sipRequest.Headers.CSeq; response.Headers.Via = sipRequest.Headers.Via; response.Headers.To = sipRequest.Headers.To; response.Headers.ContentLength = 0; return(response); }