Live data from Hacker News

TIL: You can make HTTP requests without curl using Bash /dev/TCP

mareksuppa.com

31–40 of 255 posts

Re: TIL: You can make HTTP requests without curl using Bash /dev/TCP

#31
post #12

Earlier 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…

This is the most Claude pilled comment I've seen here.

This worries me. Some AI writing styles became mainstream; at first it was the em-dashes, now it’s “A, not B” patterns and excessive acknowledging. There will be more.

Was grandparent comment written by an LLM?

Or is this a human who copies a style they saw in a blog post, unaware that they’re copying an AI?

Or is this a human who spent too much time talking to an AI and now they just talk like this?

Or is this an organic human response and we’re all paranoid by now?

I don’t know which would be worse.

Re: TIL: You can make HTTP requests without curl using Bash /dev/TCP

#32

A few years ago I had to do this for a SpringBoot health check from a Docker container: FROM openjdk:11-jre-slim HEALTHCHECK --start-period=10s --timeout=3s --retries=5 \ CMD perl -e "use IO::Socket; $sock = IO::Socket::INET->new(Proto => 'tcp', PeerAddr => 'localhost', PeerPort => '8888') or die $@; $sock->autoflush(1); print $sock 'GET /actuator/health HTTP/1.1' . chr(0x0a) . chr(0x0d) . 'Host: localhost:8888' . ch…

Note that this is not what the article is about. Bash has a fake /dev/tcp path that opens sockets. What you have there is just perl opening a socket normally. Great solution, but the interesting bit is that fake path.

Re: TIL: You can make HTTP requests without curl using Bash /dev/TCP

#33

> 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…

> No, it can not. Bash lets you open TCP sockets. I thought you had to use a program called netcat for that--if not then what is the point of that binary? And for that matter, can't you also use telnet to manually send HTTP?

nc is basically just a nicer interface for the same thing, in the same way that curl is.

https://linux.die.net/man/1/nc

Re: TIL: You can make HTTP requests without curl using Bash /dev/TCP

#34
post #16

Neat, works against example.com exec 3 /dev/tcp/example.com/80 printf 'GET / HTTP/1.1\r\nHost: example.com\r\nConnection: close\r\n\r\n' >&3 cat Outputs: HTTP/1.1 200 OK Date: Tue, 16 Jun 2026 17:37:45 GMT Content-Type: text/html ... I always end up on example.com for this kind of thing because there are so few domains these days that don't enforce https!

example.com is also great for that reason when something fails about a captive portal on a public WiFi. I open my web browser and go to http://example.com and get redirected to the captive portal page again and retry completing what they need from me to get internet access.

Fun fact, this is almost exactly how active portal detection is done in the OS/browser!

https://gist.github.com/skull-squadron/edb8c0122f902013304c0...

Re: TIL: You can make HTTP requests without curl using Bash /dev/TCP

#36
post #13

> 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…

it's not that insane. i've been manually typing http requests in since before http/1.1 and the mandatory host header. it is insane to use it for anything serious (also the opposite, implementing webservers in bash), but for quick testing it's pretty great!

Why wouldn’t you use curl for the quick test?

Re: TIL: You can make HTTP requests without curl using Bash /dev/TCP

#37
post #12

Earlier 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…

This is the most Claude pilled comment I've seen here.

what would be a non-pilled way of saying the same thing?

Re: TIL: You can make HTTP requests without curl using Bash /dev/TCP

#39
post #16

Neat, works against example.com exec 3 /dev/tcp/example.com/80 printf 'GET / HTTP/1.1\r\nHost: example.com\r\nConnection: close\r\n\r\n' >&3 cat Outputs: HTTP/1.1 200 OK Date: Tue, 16 Jun 2026 17:37:45 GMT Content-Type: text/html ... I always end up on example.com for this kind of thing because there are so few domains these days that don't enforce https!

This works too

  exec 3/dev/tcp/example.com/80
  printf 'GET / HTTP/1.1\r
  Host: example.com\r
  Connection: close\r
  \r
  ' >&3
  cat 
You can even take out the \r though they should be there

Re: TIL: You can make HTTP requests without curl using Bash /dev/TCP

#40

> 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…

> No, it can not. Bash lets you open TCP sockets. I thought you had to use a program called netcat for that--if not then what is the point of that binary? And for that matter, can't you also use telnet to manually send HTTP?

[deleted]
Post reply on HN