Conversation
Clarify what this function does: it implements the legacy HTTP API parser.
Rather add this token in to all call sites, check for it only where it matters: when we've got an HTTP request. If it's passed in other contexts, it will be safely ignored.
Internal requests are indicated by passing nullptr for the request argument. If we *are* in fact called from an HTTP request, we must generate some kind of reply anyways, so this parameter is obsolete.
No need to even consider this for non-web requests. Move the request special case to that context as well.
blazoncek
left a comment
There was a problem hiding this comment.
Seems like a good improvement. Have yet to test it, though.
|
|
||
| if(handleSet(request, request->url())) return; | ||
| if (request->url().indexOf("win") == 0) { | ||
| if (handleHttpApi(request->url().substring(3))) { |
There was a problem hiding this comment.
Is it 3 or is it 4?
I would think 4 as you do not compare & in handleHttpApi() or there is no need to add equality to comparisons there.
There was a problem hiding this comment.
The leading '&' is intentionally left on as some of the test strings in handleHttpApi() have a leading "&", eg. pos = req.indexOf(F("&S="));. I'm not really sure why some do and some don't -- I should probably just clean that up too while I'm in there.
There was a problem hiding this comment.
Actually, given that, I'm going to convert this to draft for now and do some more testing. I think there's some corner cases where this code will differ from the original.
| if(handleSet(request, request->url())) return; | ||
| if (request->url().indexOf("win") == 0) { | ||
| if (handleHttpApi(request->url().substring(3))) { | ||
| if (request->url().indexOf(F("&FX=")) > 0) { |
There was a problem hiding this comment.
Wouldn't it be better to move this into handleHttpApi()?
IMO it's place is there.
There was a problem hiding this comment.
In the original code, we call unloadPlaylist() only the FX was changed from an HTTP request, but not from any other context. It made more sense to me to place that code only in the HTTP request context, rather than add a special parameter to handleHttpApi() just to switch this call on or off. It does mean naming the tag twice, but I think that's the lesser evil -- https://sandimetz.com/blog/2016/1/20/the-wrong-abstraction
An alternative might be to augment the return code to indicate if the FX value was changed, rather than parsing the tag multiple times.
There was a problem hiding this comment.
IMO any change to FX should unload playlist - unless loaded from playlist itself.
There was a problem hiding this comment.
I agree -- although this PR was aimed to be a refactor with no behavioural changes, and the original logic only unloaded the playlist in the context of an HTTP request.
I'll do a more thorough review of the other call contexts and see if I can draw a better map. No reason not to further improve things as we go.
|
Hey! This pull request has been open for quite some time without any new comments now. It will be closed automatically in a week if no further activity occurs. |
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
|
@willmmiles shall we reopen this? |
|
Sure. It's not a burning priority but I would like to get back to it at some point. |
Along with #4271, I took the opportunity to clean up the surrounding code a small amount. This PR:
nullptrfor therequest. The conditional was broken anyhow, and HTTP requests are required to generate a response.