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

Scheme missing from URL in HttpClient_ThingSpeak sample #1945

Merged
merged 1 commit into from
Nov 5, 2019

Conversation

mikee47
Copy link
Contributor

@mikee47 mikee47 commented Nov 4, 2019

Without this port doesn't get set, attempts to connect to port 0 which fails with ERR_ABORT.

@slaff slaff added this to the 4.0.1 milestone Nov 4, 2019
@slaff slaff merged commit 5177e17 into SmingHub:develop Nov 5, 2019
@mikee47
Copy link
Contributor Author

mikee47 commented Nov 5, 2019

+LTS

@mikee47 mikee47 deleted the fix/instapush-sample branch November 5, 2019 08:06
slaff pushed a commit to slaff/Sming that referenced this pull request Nov 5, 2019
slaff pushed a commit that referenced this pull request Jun 23, 2024
This PR addresses some inconsistencies with the `Url` class.

**Ensure Url provides default port for default scheme**

When building a URL the Scheme defaults to HTTP if not specified.
This means the port should also default to 80, but it doesn't.

For example:

```
Url url;
url.Host = "api.thingspeak.com";
url.Path = "/update";
```

This produces the correct URL text `http://api.thingspeak.com/update` with the default scheme, but `getPort()` incorrectly returns 0.

See #1937 (comment),
PR #1945 provided a fix but didn't actually resolve the underlying issue.

**Url::toString() doesn't lowercase scheme**

For example:

```
Url url;
url.Scheme = "HTTP";
url.Host = "api.thingspeak.com";
url.Path = "/update";
```

Incorrectly produces `HTTP://api.thingspeak.com/update`.

**Add `Url::getQueryParameter` method**

Care is required when reading query parameters as direct access to the `Query` member variable means non-existent keys get added. Therefore a `const` cast is required. This method provides a more convenient way for safely reading values, and also allows a default to be given where the value doesn't exist.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants