Pop princess! King of Norway's granddaughter Leah Behn puts on a VERY glamorous display in hotpants watching Charli xcx at a Swedish festival... before flying back to Oslo to walk the runway
Samantha Faiers says 'timing was right' to reunite with Billie Shepherd for new ITV show
Ukraine's First Lady Olena Zelenska sends 'letter of gratitude' to Melania Trump for challenge to Putin
Revealed: The multimillion-pound bond between Phillip Schofield and his estranged wife despite marriage split after he came out as gay
Police name men charged over 'disturbance' at Brentwood petrol station
Browser wars are back, predicts Palo Alto, thanks to AI
Brace for a new round of browser wars, according to Palo Alto Networks CEO Nikesh Arora.…
CodeSOD: I Am Not 200
In theory, HTTP status codes should be easy to work with. In the 100s? You're doing some weird stuff and breaking up large requests into multiple sub-requests. 200s? It's all good. 300s? Look over there. 400s? What the hell are you trying to do? 500s? What the hell is the server trying to do?
This doesn't mean people don't endlessly find ways to make it hard. LinkedIn, for example, apparently likes to send 999s if you try and view a page without being logged in. Shopify has invented a few. Apache has added a 218 "This is Fine". And then there's WebDAV, which not only adds new status codes, but adds a whole bunch of new verbs to HTTP requests.
Francesco D sends us a "clever" attempt at handling status codes.
try { HttpRequest.Builder localVarRequestBuilder = {{operationId}}RequestBuilder({{#allParams}}{{paramName}}{{^-last}}, {{/-last}}{{/allParams}}{{#hasParams}}, {{/hasParams}}headers); return memberVarHttpClient.sendAsync( localVarRequestBuilder.build(), HttpResponse.BodyHandlers.ofString()).thenComposeAsync(localVarResponse -> { if (localVarResponse.statusCode()/ 100 != 2) { return CompletableFuture.failedFuture(getApiException("{{operationId}}", localVarResponse)); } {{#returnType}} try { String responseBody = localVarResponse.body(); return CompletableFuture.completedFuture( responseBody == null || responseBody.isBlank() ? null : memberVarObjectMapper.readValue(responseBody, new TypeReference<{{{returnType}}}>() {}) ); } catch (IOException e) { return CompletableFuture.failedFuture(new ApiException(e)); } {{/returnType}} {{^returnType}} return CompletableFuture.completedFuture(null); {{/returnType}} }); }Okay, before we get to the status code nonsense, I first have to whine about this templating language. I'm generally of the mind that generated code is a sign of bad abstractions, especially if we're talking about using a text templating engine, like this. I'm fine with hygienic macros, and even C++'s templating system for code generation, because they exist within the language. But fine, that's just my "ok boomer" opinion, so let's get into the real meat of it, which is this line:
localVarResponse.statusCode()/ 100 != 2"Hey," some developer said, "since success is in the 200 range, I'll just divide by 100, and check if it's a 2, helpfully truncating the details." Which is fine and good, except neither 100s nor 300s represent a true error, especially because if the local client is doing caching, a 304 tells us that we can used the cached version.
For Francesco, treating 300s as an error created a slew of failed requests which shouldn't have failed. It wasn't too difficult to detect- they were at least logging the entire response- but it was frustrating, if only because it seems like someone was more interested in being clever with math than actually writing good software.
A killer buy? One bedroom bungalow goes up for auction for £150,000 - but disturbing scene might make buyers think twice
Government confirms Plug-In Van Grant extension - how much can white van man save by going electric?
Concerns raised over plans for 250 homes in village that could bring 'much-needed' housing to the area
Aussie tourist gets himself in big trouble after messing with a transgender prostitute in Thailand
Busy Essex road and car park exits to shut for multiple nights as diversion routes confirmed
P2P payment service Zelle sued for enabling payment fraud hell
Infosec In Brief New York State is suing bank-owned peer-to-peer payment app Zelle, claiming that the banks behind it knew fraud was rampant on the platform but allowed scammers to conduct business with impunity.…
US Spy Chief Gabbard Says UK Agreed To Drop 'Backdoor' Mandate for Apple
Read more of this story at Slashdot.