I love that under Linux your tcp stack is a file.
TIL: You can make HTTP requests without curl using Bash /dev/TCP
151–160 of 255 posts
Re: TIL: You can make HTTP requests without curl using Bash /dev/TCP
#152why bother with /dev, all you need is a battery, a couple of needles and some length of ethernet cable
Re: TIL: You can make HTTP requests without curl using Bash /dev/TCP
#153Earlier quoted context omitted.
It seems pretty cool, but I am wondering if there's any drawback on just using images that support curl? I can't think of any and to me it's kinda a must have, even on production images
More than one ~500 employee company I've worked at has had security policies either encouraging or requiring the use of "distro-less" images - images with no OS components other than the absolute minimum required to run the application. For go binaries this meant literally nothing in the container apart from the executable. In theory it has a couple of benefits. You don't have to re-deploy your image to patch CVE's i…
Keeping in mind that containers are merely a bunch of namespaces, there's nothing stopping you from entering the same PID namespace with a different mount namespace in order to debug.
Re: TIL: You can make HTTP requests without curl using Bash /dev/TCP
#154Earlier quoted context omitted.
perhaps you meant "in previous millennium" ?
If someone referred to the "previous decade" in 2004, would you have said the same thing? As the calendar rolled from 1999 to 2000, we entered a new millennium, century, decade, year, day, ...
Every Jan 2 I start saying "last year" and every Dec I say "see you next year"
Re: TIL: You can make HTTP requests without curl using Bash /dev/TCP
#155Earlier quoted context omitted.
> No, it can not. Bash lets you open TCP sockets. Very fair pushback -- I did get carried away and will update the article to be more precise. Thanks for raising it! > For less insane, non-bash shells there is always nc which is usually probably the wiser choice. For completeness, `nc` or any netcat equvialent I could think of was not available in the image I was trying this with. It would certainly be a better optio…
FWIW, I didn't read this as AI-like. Even on a re-read, it's only the quasi-em-dash, and _maybe_ the polite acknowledgement of "Very fair pushback" (just good etiquette, IMO!) that would ring any alarm bells. You're fine.
Re: TIL: You can make HTTP requests without curl using Bash /dev/TCP
#156> As it turns out, bash can speak HTTP by itself. No, it can not. Bash lets you open TCP sockets. What you are doing here is trying to speak HTTP yourself, which is fine for testing and debugging, and hella cool for fun to do by hand, but you will shoot yourself in the foot if you try to use this pseudo http client unattended in reality. This toy code does not parse HTTP properly and will break. You could of course w…
Need to be clear that "full http server in pure bash" is incorrect. Bash cannot listen on a TCP/UDP socket for incoming connections. bash-web-server project builds a C language socket listener [0] that is dynamically loaded at run-time as a "built-in" module that makes the functionality available. [0] https://github.com/bahamas10/bash-web-server/tree/main/loada...
Re: TIL: You can make HTTP requests without curl using Bash /dev/TCP
#157I ran into this while checking connectivity between containers on an internal Docker network where the image had neither curl nor wget. The main surprise was that Bash has /dev/tcp which lets you do the equivalent of an HTTP request with a bit of shell magic, for instance: exec 3 /dev/tcp/service/8642 printf 'GET /health HTTP/1.1\r\nHost: service\r\nConnection: close\r\n\r\n' >&3 cat Where `service` is just the hostn…
It seems pretty cool, but I am wondering if there's any drawback on just using images that support curl? I can't think of any and to me it's kinda a must have, even on production images
Re: TIL: You can make HTTP requests without curl using Bash /dev/TCP
#158Earlier quoted context omitted.
Because curl is not installed in minimal docker images.
neither is bash or even sh for that matter :) if you have bash, you probably have apk or apt
Re: TIL: You can make HTTP requests without curl using Bash /dev/TCP
#159Earlier quoted context omitted.
If someone referred to the "previous decade" in 2004, would you have said the same thing? As the calendar rolled from 1999 to 2000, we entered a new millennium, century, decade, year, day, ...
Yes, absolutely. I use the largest interval any time I can get away with it! Every Jan 2 I start saying "last year" and every Dec I say "see you next year"
Re: TIL: You can make HTTP requests without curl using Bash /dev/TCP
#160Earlier quoted context omitted.
perhaps you meant "in previous millennium" ?
If someone referred to the "previous decade" in 2004, would you have said the same thing? As the calendar rolled from 1999 to 2000, we entered a new millennium, century, decade, year, day, ...