DEV Community

Cover image for From GET/POST to Full REST: My Recent PacketSender HTTP Verbs PR
Tomas Gallucci
Tomas Gallucci

Posted on

From GET/POST to Full REST: My Recent PacketSender HTTP Verbs PR

PacketSender is an Open Source, low-level networking tool that, until a few days ago, only supported HTTP/S POST and GET.

As I write these words, I'm waiting on final review and approval for adding PUT, PATCH and DELETE support.

How I got Involved with this Work

I’ve made previous contributions to PacketSender, some of which I'd like to explore in other posts.

I've been out of professional work for a long time. COVID really screwed everything up and the whipsaw of fire everybody, hire as many people as you can, fire them again, replace them with AI has not been my friend.

In the interim, I’ve been trying to keep my skills sharp.

When I reached out to Dan Nagle, the author and maintainer, asking if there were any open areas where I could help, he pointed me to some client-funded work around expanding HTTP verb support (PUT, PATCH and DELETE).

What do we Program?

Somewhere along the way, the way we talk about programming changed.

When I first got into this field, the literature loved to say we were “programming the processor.” It painted this romantic image of directly commanding the silicon.

Of course, this was after the industry evolved from machines that took up entire buildings, then shrank to rooms, corners of rooms. Mainframes and so-called minicomputers were on that path. Personal Computers or PCs had long since become ubiquitous when I got interested in computers, but they were still a long way from or more being in everyone's home. Now we carry them in our pockets.

It rarely true that one programs the hardware these days. Web developers use JavaScript to program web browsers. Application development is programming operating systems and sometimes windowing systems.

PacketSender is a C++ application that sits on top of Qt.

From my perspective, I initially thought the work involved was going to be adding a few commands inside PaketSender to tell Qt how to handle the request. That turned out to be the case, but there was a moment or two of panic during this journey.

Programming Qt

As you can see from the comments, Dan knew that Qt supported both PUT and DELTE. PATCH was potentially dodgier. It turns out, all three are supported by Qt, but not all three have direct support.

} else if (sendpacket.isPUT()) {
            http->put(request, bytes);
        } else if (sendpacket.isPATCH()) {
            http->sendCustomRequest(request, "PATCH", bytes);
        } else if (sendpacket.isDELETE()) {
            if (bytes.isEmpty()) {
                http->deleteResource(request);
            } else {
                http->sendCustomRequest(request, "DELETE", bytes );
            }
Enter fullscreen mode Exit fullscreen mode

direct Github PR diff link

As you can see from the code above, PUT is directly supported. DELETE has a funny name, but it works. But to get PATCH and DELETE with data to work, we have to use sendCustomRequest. And that's not terrible. Why these aren't directly supported in Qt6 is beyond me, but it isn't too onerous to get support working.

But just because we can send the HTTP/S requests, that doesn't mean we're done. We have to get data from the user to send.

PacketSender is not Postman

As of this writing, PacketSender does not support custom HTTP headers. That feature could be added.

PacketSender is an Open Source project. Like all Open Source projects, time, talent and treasure) are always welcome.

In my personal opinion, PacketSender shouldn't become the next Postman.

PacketSender's core strength has always been as a lightweight, low-level networking tool. It lets you send raw TCP and UDP packets with fine-grained control. HTTP support was added as a convenience layer on top of that foundation — not as the main focus.

Postman is a specialized API testing tool with all the complexity that comes with it (headers, auth flows, collections, environments, etc.). Trying to turn PacketSender into a full-featured HTTP client would require significant work on both the backend logic and the UI. Doing so would risk diluting what makes PacketSender valuable in the first place.

I believe there's still a strong place for a simpler, more surgical tool focused on raw networking operations.

I also think there is a market for less complicated Postman clones that don't require subscriptions or suffer from enshitification.

Documentation is Part of Development

I updated the README to include all the HTTP verbs that PacketSender will support once my PR is merged.

And I included an example request for each of the new verbs. However, you'll only get the new packets on a fresh install or if you delete the packet database. Perhaps I could add an enhancement that would add those packets if they didn't already exist. Reach out if you'd like for me to add a feature that will update the list of packets automagically when PackeSender starts.

Working with Qt Designer

This was the first time I had worked with Qt Designer. Being entirely unfamiliar with the tool, I thought I was going to have a steep learning curve.

I must admit that when I first looked at the interface in Qt Designer, I wasn't sure how to add the new verbs and protocols to the dropdown list along with their associated icons. Adding the entries was easy enough: double-click on the drop down, highlight the row you want to add your new entry under and click the plus sign.

So far, so good.

But the icon was tricker.

See, if you click the three dots, it opens a dialog that gives you a list of icons to choose from. But that list doesn't contain icons that are already in the UI you're designing. It's a list of, from what I can tell, generic icons.

I couldn't find a way to get a dialog that would allow me to upload an icon.

It turns out this "one weird trick..."

While working on a relatively large effort to fix a reported bug, I learned that Qt has a system called, creatively enough, the QT Resource System. In a sentence, the Qt Resource System adds files to your executable so you only have the one file to distribute.

On a meta level, this is similar to how SQLite gets compiled into your binary.

As you can see in the screenshot above, you have the option to both copy and paste a resource path for a file that is part of Qt's Resource System. Following this flowchart, I learned this part of Qt Designer. Q Designer, in turn, updates .ui files in the project. .ui files are renamed xml documents with. .ui extension, and thus suitable for version control.

Sprinkling in a bit of Surprise and Delight

As part of the PR, I added a feature to solve an annoyance of mine while manually testing my changes.

As I'm sure most of you who have read this far know, HTTP and HTTPS have default ports. What was annoying to me was switching between HTTP and HTTPS (and the other way around) meant having to manually change the port numbers.

I immediately thought there had to be a better user experience...and I created one!

Now, if you currently have selected an HTTP request type and switch to an HTTPS request type AND the port is the default HTTP port of 80, when you switch to HTTPS, I update the port to 443. Likewise, if you're currently on an HTTPS request type with the default port of 443 and switch to an HTTP request type, I change the port to 80. Saves the user from having to update the port.

I didn't formally document this feature outside of what you just read and explaining it in the PR. The commit is here if you want to see the code.


This was a fun PR to work on. If you found any of this useful or want to support continued improvements to PacketSender, you can donate via PayPal.

I’m also open to new opportunities; feel free to reach out.

Top comments (0)