lbussy / LCBUrl

Arduino library for handling URLs
MIT License
7 stars 1 forks source link

`getPort()` return the default `http` port, not the one from the URL #13

Closed spouliot closed 3 years ago

spouliot commented 3 years ago

Basic Infos

Platform

Settings in IDE

Problem Description

It seems getPort() return the scheme's default instead of the port provided in the URL.

MCVE Sketch


#include <Arduino.h>

void setup() {

}

void loop() {
  LCBUrl parser;
  if (parser.setUrl ("http://192.168.2.16:5000/")) {
    Serial.printf ("Host: %s\n", parser.getHost().c_str());
    Serial.printf ("Port: %d\n", parser.getPort());
  }
  delay (5000);
}

Debug Messages

Host: 192.168.2.16
Port: 80
...
lbussy commented 3 years ago

Well that's not right, is it? :) I'll have a look.

spouliot commented 3 years ago

getRawAuthority returns 192.168.2.16:5000 so endloc will be -1 and port won't be assigned

-            if ((startloc != -1) && (endloc != -1))
+            if (startloc != -1)

^ that fix the issue for me.

That might have regressed when you removed the last / ?

lbussy commented 3 years ago

Probably. I've yet to find a good way to white box test myself. It's like playing chess with yourself and expecting something to change.

lbussy commented 3 years ago

In devel, ready to be tested.