Extract HttpUserAgent class from HttpSM#9869
Conversation
f153eaa to
5846e2f
Compare
maskit
left a comment
There was a problem hiding this comment.
I'm fine with making changes step by step, but I'd like to see the big picture before making changes.
HttpSMHandler, HttpVC_t and HttpVCTableEntry probably need a better place.
|
My objective is to move some of the logic for response headers into this new class. For example, |
|
Hmm, the goal is still unclear to me. If it's going to be like we can get anything about a user agent from |
|
I wanted to split up the class a bit based on the single responsibility principle to make it more manageable. I did not have a long-term vision of how the refactoring would continue, but I'd like to try moving the other client fields over (in this PR) like you suggested, and splitting out I'm pretty new to the codebase and it's not very clear to me yet which fields belong together. I thought client and user agent were somehow different concepts in the codebase, because they are named differently. |
|
The goal is to encapsulate these fields such that the state machine doesn't need to access this data at all. If it has less data it has to manage directly it will be a lot easier to follow the logic. I want to move operations on client and server data out of the state machine, so that the state machine focuses on changing between states correctly and delegates the details of changing the state to those new classes. |
|
Thanks for the clarification.
Sounds reasonable. You've already answered my question on the other comment but I was not sure what the responsibility of the new class where you have only one for user agent side.
I'd say nobody fully understand the concepts 🙂 The two terms might have been used for a client on HTTP layer and a client on TCP layer, but this is just my guess.
Sounds great. Let's make it happen. |
28a3007 to
e1dc4ad
Compare
|
Rebased on master due to merge conflict. |
e1dc4ad to
1035d35
Compare
1035d35 to
b708860
Compare
|
Rebased on master. |
|
[approve ci autest] |
|
The autest failure on this one indicates a real problem. I've been working on it but debugging the state machine without unit tests is a relatively large time sink. |
|
I found the bug. I missed a single !, and I think I spent as much time finding that single missing ! as I spent making this entire PR. I'm going to add a unit test that covers that case, but I'm encountering a lot of segfaults in the test setup. |
b708860 to
df22de9
Compare
|
Rebased on master. Some unfinished changes also got pushed by mistake. |
This extracts a new class with 3 fields (entry, raw_buffer_reader, and txn). It doesn't have much responsibility yet. But it does provide a starting point for moving some behavior out of the state machine.
This introduces HttpVCTable.h and HttpVCTable.cc to hold all the stuff related to the HttpVCTable struct.
This moves all the client_ fields except the byte counts into HttpUserAgent, and sets most of the fields when the transaction is set.
This matches the behavior of the original code, and may be important.
A not (!) operator was missed, which caused tcp_reused to be set incorrectly on the user agent. This fixes the issue, and adds Catch tests to check for regression.
There is one segfault left to fix.
7292945 to
acf0f03
Compare
|
Rebased on master to resolve merge conflict. |
79708a0 to
0dfbfef
Compare
|
I'm wondering whether it's worth it to build the new test in the automake build. In the CMake build it was convenient to build a single test executable, but the automake build has things split into multiple test executables, and building the one new test would require a large amount of boilerplate (linking 10+ libs or whatnot), and I'm hoping the automake build will eventually be removed anyway so we don't have to maintain two build generators. |
| } | ||
|
|
||
| inline ProxyTransaction * | ||
| HttpSM::get_ua_txn() |
There was a problem hiding this comment.
I wondered if we should keep this because now we can do sm->get_user_agent()->get_txn(). Maybe we should keep it, so we can get a user-agent transaction and a server transaction in a consistent way.
maskit
left a comment
There was a problem hiding this comment.
Looks good. Assuming functions are just moved and there's no logic change.
|
There isn't supposed to be any logic change. The AuTests passing and the relative simplicity of the change (most of the code was directly copy/pasted) gives me a little confidence that the behavior is preserved, and I am planning to add some more unit tests in a followup PR. |
This extracts a new class with 3 fields (entry, raw_buffer_reader, and txn). It doesn't have much responsibility yet. But it does provide a starting point for moving some behavior out of the state machine.
Edit: We extracted a lot more fields, and moved HttpVCTable to its own file.