I had a similiar case with influeza the past december. I didn't eat for 4 days, fever for a long time, and low energy during the whole 4 weeks it took me to get back to normal.
I couldn't drink coffee or alcohol during those 4 weeks, and notice that I didn't get any migraines after those 4 weeks even when I, for the past 12 years, knew exactly how I got them reliably.
I didn't make sense to me to keep drinking coffee because the benefits of coffee which for me was mostly ritual and taste, didn't outweight the weight of having a migraine for sure if I slept a minute less than 8hrs.
Mind you, I'm talking about a cup almost everyday with milk, ice coffee in the mornings.
I had wild food poisoning and had a similar experience (took me out for weeks, didn’t drink coffee). I assume the body must have some sort of gating mechanism for pain; I have absolutely had caffeine withdrawal before, but not that time. I’ve since cut back and switched to tea, which I believe has helped with my anxiety.