/// <summary> /// Creates a debug string for spamming the display with too much information /// </summary> /// <returns>A formatted debug string</returns> public override string ToString() { return ("CurrentColumn: " + CurrentColumn.ToString() + "\n" + "CurrentRow:" + CurrentRow.ToString() + "\n" + "ApplicationCursorKeysMode:" + ApplicationCursorKeysMode.ToString() + "\n" + "Attribute:\n" + Attributes.ToString() + "\n" + "TabStops:" + string.Join(",", TabStops.Select(x => x.ToString()).ToList()) + "\n" + "WordWrap:" + WordWrap.ToString() + "\n" + "ReverseVideoMode:" + ReverseVideoMode.ToString() + "\n" + "OriginMode:" + OriginMode.ToString() + "\n" + "InsertMode:" + InsertMode.ToString() + "\n" + "ShowCursor:" + ShowCursor.ToString() + "\n" + "BlinkingCursor:" + BlinkingCursor.ToString() + "\n" + "CursorShape:" + CursorShape.ToString() + "\n" + "Utf8:" + Utf8.ToString() + "\n" + "CharacterSetMode:" + CharacterSetMode.ToString() + "\n" + "G0:" + G0.ToString() + "\n" + "G1:" + G1.ToString() + "\n" + "G2:" + G2.ToString() + "\n" + "G3:" + G3.ToString() + "\n" + "Vt300G1:" + Vt300G1.ToString() + "\n" + "Vt300G2:" + Vt300G2.ToString() + "\n" + "Vt300G3:" + Vt300G3.ToString() + "\n" + "Vt52AlternateKeypad: " + Vt52AlternateKeypad.ToString() + "\n" + "Vt52GraphicsMode: " + Vt52GraphicsMode.ToString() + "\n" + "AutomaticNewLine:" + AutomaticNewLine.ToString() + "\n" + "ConfiguredColumns:" + ConfiguredColumns.ToString() + "\n" + "National Character Replacement Mode:" + NationalCharacterReplacementMode.ToString() + "\n" + "Single shift character mode:" + SingleShiftSelectCharacterMode.ToString() + "\n" ); }
public override void AddHeader(Header header) { var valueString = Utf8.ToString(header.Value); var nameString = Utf8.ToString(header.Name); AddHeader(nameString, valueString); }
internal String ToStringUTF8(sbyte[] ba, int len) { if (IsUTF8) { return(ToString(ba, len)); } if (Utf8 == null) { Utf8 = new ZipCoder(StandardCharsets.UTF_8); } return(Utf8.ToString(ba, len)); }
async Task SendAsync() { PipeReader reader = _requestPipe.Reader; try { while (true) { ReadResult result = await reader.ReadAsync(); ReadOnlySequence <byte> buffer = result.Buffer; try { if (!buffer.IsEmpty) { for (SequencePosition position = buffer.Start; buffer.TryGet(ref position, out ReadOnlyMemory <byte> segment);) { if (Log != null && Log.Switch.ShouldTrace(TraceEventType.Verbose)) { string data = Utf8.ToString(segment.Span); if (!string.IsNullOrWhiteSpace(data)) { Log.TraceInformation(data); } } await WriteToSocketAsync(segment).ConfigureAwait(false); } } else if (result.IsCompleted) { break; } } finally { reader.AdvanceTo(buffer.End); } } } catch (Exception e) { Log.TraceEvent(TraceEventType.Error, 0, e.ToString()); } finally { reader.Complete(); } }
void VerifyUserAgentHeader(HttpRequestMessage request) { var expected = Utf8.ToString(Header.Common.CreateUserAgent("Azure.Configuration", "1.0.0").Value); Assert.True(request.Headers.Contains("User-Agent")); var userAgentValues = request.Headers.GetValues("User-Agent"); foreach (var value in userAgentValues) { if (expected.StartsWith(value)) { return; } } Assert.Fail("could not find User-Agent header value " + expected); }
protected internal override bool TryGetHeader(ReadOnlySpan <byte> name, out ReadOnlySpan <byte> value) { string nameString = Utf8.ToString(name); if (!_responseMessage.Headers.TryGetValues(nameString, out var values)) { if (!_responseMessage.Content.Headers.TryGetValues(nameString, out values)) { value = default; return(false); } } var all = string.Join(",", values); value = Encoding.ASCII.GetBytes(all); return(true); }
public static void LogRequest(this Log log, HttpRequest request, ReadOnlySequence <byte> body) { if (log.IsVerbose) { // TODO: this is much ceremony. We need to do something with this. ReadOnlyBytes.AsUtf8 maybe? log.LogMessage(Log.Level.Verbose, "\tMethod: {0}", request.Method); log.LogMessage(Log.Level.Verbose, "\tRequest-URI: {0}", request.Path); log.LogMessage(Log.Level.Verbose, "\tHTTP-Version: {0}", request.Version); log.LogMessage(Log.Level.Verbose, "\tHttp Headers:"); var headers = request.Headers; for (int i = 0; i < headers.Length; i++) { var header = headers[i]; log.LogMessage(Log.Level.Verbose, "\t\t{0}: {1}", Utf8.ToString(header.Name), Utf8.ToString(header.Value)); } // TODO: Logger should support Utf8Span log.LogMessage(Log.Level.Verbose, Utf8.ToString(body.First.Span)); } }
async Task ReceiveAsync() { PipeWriter writer = _responsePipe.Writer; try { while (true) { // just wait for data in the socket await ReadFromSocketAsync(Memory <byte> .Empty); while (HasData) { Memory <byte> buffer = writer.GetMemory(); int readBytes = await ReadFromSocketAsync(buffer).ConfigureAwait(false); if (readBytes == 0) { break; } if (Log != null && Log.Switch.ShouldTrace(TraceEventType.Verbose)) { string data = Utf8.ToString(buffer.Span.Slice(0, readBytes)); if (!string.IsNullOrWhiteSpace(data)) { Log.TraceInformation(data); } } writer.Advance(readBytes); await writer.FlushAsync(); } } } finally { writer.Complete(); } }