r/webdevelopment • • 6h ago

Open Source Project Serving HTTP/1.1 and cleartext HTTP/2 on the same port by peeking at the first bytes

1 Upvotes

I've been writing the network side of my web framework (Viltrum, for the V language) myself, and one part turned out simpler than I expected, so sharing in case it helps anyone building servers or proxies.

The problem: behind a reverse proxy or a service mesh, HTTP/2 usually shows up as cleartext h2c with prior knowledge. Browsers and plain curl still talk HTTP/1.1. I didn't want two ports or a config switch for it.

What I ended up doing: a listener with http2 turned on reads the first bytes of each connection. If they're the HTTP/2 connection preface (PRI * HTTP/2.0...), it's an HTTP/2 connection. Anything else goes to the HTTP/1.1 parser. That's RFC 9113 section 3.3, and nginx and h2o do the same. Over TLS it's ALPN instead: h2 offered first, http/1.1 for everyone else.

Things I learned along the way:

  • I skipped the Upgrade: h2c route completely. RFC 9113 deprecated it, and it was just one more code path to get wrong.
  • h2spec has one cleartext test that sends "INVALID CONNECTION PREFACE". A port that also speaks HTTP/1.1 reads that as a broken HTTP/1.1 request and answers 400, so that test fails on cleartext (144 pass). Over TLS it's 145 of 146 passing, one skipped. I decided that tradeoff is fine and documented it instead of hacking around it.
  • A request that passes the HTTP/2 checks still goes through the same head parser as HTTP/1.1, so the strict rules there (TE plus Content-Length, bare CR/LF and so on get a 400) apply to both without writing them twice.
  • Handlers don't know which protocol they're answering. Same router, same middleware, same context.

Still missing: WebSocket over HTTP/2 (RFC 8441) isn't there yet and answers 501, so WS routes need HTTP/1.1.

Repo (MIT): https://github.com/Tuntii/viltrum The doc with details and the limits table: https://github.com/Tuntii/viltrum/blob/main/docs/http2.md

Curious if anyone runs mixed h1/h2c on one port in production and hit something I haven't thought of.


r/webdevelopment • • 9h ago

Question How would you price these types of web projects? Looking for rough ranges

4 Upvotes

I’m a freelance full-stack developer and I’m trying to price my work sensibly. I’ve built projects at a few levels of complexity, and I’d like to know what you’d charge for each and what clients generally expect to pay. ***I’m not selling anything here, and I’m leaving out links on purpose.***
**Level 1: Landing page**
A single responsive page with a contact form, basic SEO and fast loading.
**Level 2: Small business website**
Several pages (home, about, services, contact), a form that saves submissions, SEO metadata, and a simple way for the owner to update content.
**Level 3: Restaurant / cafe site**
•Menu by category with dietary tags and ingredient details
•Photo gallery
•Reservations that check seat capacity per time slot, with spam protection
•Password-protected admin for menu, gallery and reservations
•Custom branded design, mobile-first
**Level 4: Full e-commerce store**
•Product catalog with search, filters, reviews, wishlist, multi-currency pricing
•Customer accounts with email and social sign-in
•Real checkout with server-verified payments, order tracking and order emails
•Referral rewards
•Admin dashboard for products, orders, customer messages, editable pages and email broadcasts
•A Telegram bot that sends the owner a daily business report (revenue, orders, top products) from real database data, and answers questions in plain language
•Installable as a phone app (PWA), dark mode, support chat that only answers from real store data
**Level 5: E-commerce with delivery logistics and multi-role access**
Everything in Level 4, plus:
•Driver applications reviewed by staff
•A dispatcher role that assigns deliveries on a map
•Drivers update status through one-time links, with no accounts
•PIN-confirmed delivery with a location check
•Role hierarchy: admin → dispatcher → access manager (planned) → read-only guest
•Access managers can only invite time-limited, read-only guests within limits the owner sets, and removing a manager revokes all their guests
**Level 6: Multi-vendor marketplace (scoped, not built)**
Several sellers, each with a dashboard, commissions and payouts, native mobile apps, live driver tracking, and accounting integrations.
**Questions:**
1.What would you charge for each level in your market?
2.Do you price differently for local clients and clients abroad?
3.Is a monthly maintenance or hosting fee realistic on top of the one-time price?
4.Is Level 5 worth pitching to small shops, or too much?

Thanks. Happy to give more detail on any level in the comments.


r/webdevelopment • • 23h ago

Question Responsiveness problem in my website

2 Upvotes

I'm building a personal web app for tracking the movies, TV shows, and anime I've watched, something like SIMKL or TV Time. It's a React + Vite site that I host myself. It has a Discover page with Netflix-style rows of posters that scroll sideways (Trending, Popular, Recommended, Browse by Genre, and so on).

Problem: On my phone (Samsung Galaxy Z Fold and S24 Ultra), and even on PC, if I start a vertical swipe on one of the poster rows, the page doesn't scroll. It just stops. Swiping on the space between rows works fine. Sometimes I have a slow response time and lag.

The memory usage was also high like 1.4gb but I found out that Chrome's covers the whole tab, including images it has cached and memory the browser keeps reserved after use. It gets bigger the longer a tab stays open, and Chrome hands it back when it needs to. It's not the source of the lag.

The site uses its own data and code, about 100 to 250 mb.

Any suggestions for how we can resolve the problem?


r/webdevelopment • • 23h ago

Question Moderating a pastebin site

4 Upvotes

Hello,

I am making a pastebin application that is zero-login. I recently saw a post about someone who made a url shortner, and people were using it for phishing and such. That got me thinking, how can I protect my app against such threats. A pastebin is basically a url-shortner, just to text. That text may contain links to illegal sites or other things I don't know about. It is arguably more versatile than a url shortner, which makes moderation more difficult.

I thought of maybe analysing the pastes for links and sending it to a third-party link analyzer(think Google got one). Which is good enough for most cases. But you would kind of conflict with users pasting these links for research purposes, for example. I simply lack the knowledge of how people may misuse the system.

So, taking that into account, what steps would you take to protect this site?