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

Use netcat instead of curl to save space #14

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

nstrelow
Copy link

@nstrelow nstrelow commented Dec 5, 2018

Curl is very feature rich, but comes as a heavy package, which is not needed for the simple POST to HA.

Use netcat instead, which is included in busybox by default.
While building, DEPENDS ensures that if netcat is not included in busybox, the full version of netcat is included.

Size comparison according to openwrt pkgdata:
curl(42kB)+libcurl=(99kB) = 141kB
netcat (if not included) = 12kB

Closes #13

echo
echo $payload;
sleep 1
) | nc $hass_host 8123`
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

harcoded port

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch 👍

@@ -1,5 +1,6 @@
config hass 'global'
option host 'ip.or.name.example:8123'
option host 'ip.or.name.example'
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not just split/cut the previous host option to maintain backwards compatibility?

Copy link
Author

@nstrelow nstrelow Dec 5, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, because now port is mandatory.
I could default to 80 if no port is given

@mueslo
Copy link
Owner

mueslo commented Dec 5, 2018

Thanks for your efforts. This is a regression though (no https, redirect, iffy response handling with sleep, etc.), so I think the best approach would be to build a separate -tiny package.

@nstrelow
Copy link
Author

nstrelow commented Dec 5, 2018

The netcat package has a lot more options than the busybox version, which has no way of setting anything besides the host and port. Therefore some workarounds and possible downsides.

The "real" netcat package supports waiting for the output of the command, so I could remove sleep.
I think it supports https, not sure about redirects.

Any idea how I could test this?

@SamJongenelen
Copy link
Contributor

@nstrelow http redirect (301) is supported with netcat, according to this page:
http://infoheap.com/use-netcat-nc-to-test-http-url-redirection/

@ohadlevy
Copy link

I still think https out of the box is very useful

@mueslo
Copy link
Owner

mueslo commented Nov 22, 2019

if you want this to be implemented it needs to be a separate code path, not replace the curl version

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

Successfully merging this pull request may close these issues.

Libcurl to big for tiny flash router (4MB)
4 participants