Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to handle query parameters with no "=" separator? #13

Open
jpbro opened this issue Dec 29, 2017 · 1 comment
Open

How to handle query parameters with no "=" separator? #13

jpbro opened this issue Dec 29, 2017 · 1 comment
Assignees
Labels

Comments

@jpbro
Copy link
Owner

jpbro commented Dec 29, 2017

Thought I pose this as a question in case anyone out there had an insights/preferences.

Consider the following URL:

http://localhost/myapp.fcgi?test

Where test is the query string.

In the current VbFcgi implementation, test is treated as a default parameter value. Calling CHttpQueryParams.DefaultValue returns test, and calling CHttpQueryParams.ValuesByKey("") returns a CHttpQueryParamValues object with a single value of test.

I'm thinking it might be better to treat test as a "flag" and use it as a key instead of a value. So calling CHttpQueryParams.Exists("test") would return True and calling CHttpQueryParams.ValuesByKey("test") would return a CHttpQueryParamValues object with zero values.

Perhaps the best of both worlds would be an option property to let users decide which approach to take based on the needs of their FCGI applications?

@jpbro jpbro added the question label Dec 29, 2017
@jpbro jpbro self-assigned this Dec 29, 2017
@skacurt
Copy link

skacurt commented Feb 16, 2019

Both ASP Classic and PHP treats ?test as a key with a zero length string value.

PHP:

<?php
echo $_SERVER["QUERY_STRING"]."<br>";
if(isset($_GET["test"]) && gettype($_GET["test"]) == "string" && $_GET["test"] == "")
	echo "OK";

ASP Classic:

<%
Response.Write Request.ServerVariables("QUERY_STRING") & "<br>"
If Request.QueryString("test").Count = 1 And VarType(Request.QueryString("test")) = vbString And Request.QueryString("test") = "" Then
	Response.Write "OK"
End If
%>

Both prints:

test
OK

I would go with this approach by default, but providing an option to change the behavior would also be good.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants