Skip to content

ESP8266WebServer parsing query part of URI #2611

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

Closed
holgerlembke opened this issue Oct 16, 2016 · 4 comments
Closed

ESP8266WebServer parsing query part of URI #2611

holgerlembke opened this issue Oct 16, 2016 · 4 comments

Comments

@holgerlembke
Copy link
Contributor

holgerlembke commented Oct 16, 2016

If I send a

   http://xxxx/index.html?foo=baa

I get an args() result. If I send a

   http://xxxx/index.html?foo

the foo is lost, no args(), nothing.

I'm not suure how to solve that. Perhaps add a foo-argname with an empty arg.

@holgerlembke
Copy link
Contributor Author

holgerlembke commented Oct 16, 2016

Perhaps this is a solution:

  int hasSearch = url.indexOf('?');
  if (hasSearch != -1){
    searchStr = url.substring(hasSearch + 1);
    if (searchStr.indexOf('=')==-1) {
        searchStr="query="+searchStr;
    }
    url = url.substring(0, hasSearch);
  }
  _currentUri = url;

@devyte
Copy link
Collaborator

devyte commented Oct 11, 2017

@holgerlembke You are right, but I know that
http://xxxx/index.html?foo=
works.
A quick google shows that the relevant RFC is not specific on this matter, meaning that it is implementation defined. ASP seems to choke on what you propose, but other parsers accept it.
I think this should be fixed, makes for better compatibility.

@holgerlembke
Copy link
Contributor Author

For concept compatibility it might be an approach to make it like php.

$_SERVER["argv"] = Array
(
    [0] => foo
)

jasonharper added a commit to jasonharper/Arduino that referenced this issue Mar 26, 2018
…ted, as a key with an empty value. Previous behavior was to completely ignore the argument, yet still include it in the argument count.

(The use of "key=value" arguments is a convention, not an actual requirement in URLs.)

Fixes bug esp8266#2611.
@devyte
Copy link
Collaborator

devyte commented Oct 17, 2018

Fixed with #5252 .

@devyte devyte closed this as completed Oct 17, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants