Changeset 471


Ignore:
Timestamp:
Aug 21, 2023, 1:32:40 PM (15 months ago)
Author:
alloc
Message:

Fixed: Possibly multiple parsing of query string

Location:
TFP-WebServer/WebServer/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • TFP-WebServer/WebServer/src/RequestContext.cs

    r426 r471  
     1using System.Collections.Specialized;
    12using SpaceWizards.HttpListener;
    23
     
    67                public readonly ERequestMethod Method;
    78                public readonly HttpListenerRequest Request;
     9                private NameValueCollection queryParameters;
    810                public readonly HttpListenerResponse Response;
    911                public readonly WebConnection Connection;
    1012                public readonly int PermissionLevel;
     13
     14                public NameValueCollection QueryParameters => queryParameters ??= Request.QueryString;
    1115
    1216                public RequestContext (string _requestPath, HttpListenerRequest _request, HttpListenerResponse _response, WebConnection _connection, int _permissionLevel) {
  • TFP-WebServer/WebServer/src/WebAPI/APIs/Log.openapi.yaml

    r467 r471  
    8787
    8888paths:
    89   /api/Log:
     89  /api/log:
    9090    get:
    9191      tags:
  • TFP-WebServer/WebServer/src/WebAPI/APIs/LogApi.cs

    r467 r471  
    2323
    2424                protected override void HandleRestGet (RequestContext _context) {
    25                         if (_context.Request.QueryString ["count"] == null || !int.TryParse (_context.Request.QueryString ["count"], out int count)) {
     25                        if (_context.QueryParameters ["count"] == null || !int.TryParse (_context.QueryParameters ["count"], out int count)) {
    2626                                count = 50;
    2727                        }
     
    3939                        }
    4040
    41                         if (_context.Request.QueryString ["firstLine"] == null || !int.TryParse (_context.Request.QueryString ["firstLine"], out int firstLine)) {
     41                        if (_context.QueryParameters ["firstLine"] == null || !int.TryParse (_context.QueryParameters ["firstLine"], out int firstLine)) {
    4242                                firstLine = count > 0 ? LogBuffer.Instance.OldestLine : LogBuffer.Instance.LatestLine;
    4343                        }
Note: See TracChangeset for help on using the changeset viewer.