softwareconstruction240 / softwareconstruction

Content for BYU CS 240: Advanced Software Construction
MIT License
47 stars 43 forks source link

PetShop: Use HttpClient instead of HttpURLConnection #169

Open 21aslade opened 1 week ago

21aslade commented 1 week ago

Currently, PetShop's ServerFacade uses HttpURLConnection to make requests. HttpURLConnection's API is rather unintuitive and bulky, and JDK 11 provided HttpClient as a replacement.

Switching to HttpClient makes the requests simpler and more representative of a modern approach to http. It would also close #157, #160, and #163, asHttpClient's api does not differentiate between the input stream and the error stream.

I'm happy to provide the code/docs changes! They're all relatively simple. I just wanted to make an issue before making a PR to give some heads up.

frozenfrank commented 1 week ago

@21aslade Thank you for submitting this issue! Thank you for concisely summing up the problem and proposing a meaningful solution. You've done an amazing job providing links to our prior efforts to address the issue.

Additional research confirms that this proposal is legit. See the related resources:

Personally, I like the upgrade approach a lot more than our previous attempts. I would love to see a PR that performs the upgrade. Recognizing that I have no actual authority, you may choose to wait for a more meaningful approval from @leesjensen or @jerodw.

leesjensen commented 6 days ago

Love it! We just need to update the following:

Totally worth doing though. I thought I remembered an easier way to do client requests in Java!

@rodham @jerodw - what do you think?