Note that $\int_0^\infty f(x) = \frac{1}{2} \int_{-\infty}^\infty f(x)$. You can use the punctured half-circle contour (like half of a CD, in the upper half plane) to integrate $f(z)$, then apply the residue theorem, note that half of your contour is your integral, and take care of the other half by bounding it.
Like you said, $f(z)$ has poles in your contour at $p_1 = e^{i\pi/4}, p_2 = e^{i3\pi/4}$. It's a fact that these poles are simple, and that's not too hard to show. Hence $f = \frac{p}{q}$ implies that $\text{Res}_{p_i} f = \frac{p(p_i)}{q'(p_i)}$.
Now, call your CD contour $\gamma$ and the residue at $p_i$ as $r_i$. The residue theorem states that $\int_\gamma f = 2\pi i (r_1 + r_2)$. But if you let the circle part of $\gamma$ be $\gamma_C$ then $\int_\gamma f = 2*\int_0^R f + \int_{\gamma_C}f$, and $|\int_{\gamma_C} f| \leq \int_{\gamma_C} |f| \leq len(\gamma_C) * \frac{R^2 + 1}{R^4 + 1} = \frac{R^3 + R}{R^4 + 1} \to 0$ as $R \to \infty$, where $R$ is the radius of $\gamma$. Hence you can ignore the circle part and obtain the result.
Edit: The theorem about rational functions and simple poles. Suppose $f(z) = \frac{p(z)}{q(z)}$ and $f$ has a simple pole at $a$. Then the formula for residues says that $\text{Res}_a f = \lim_{z \to a} (z-a)f(z) = \lim_{z \to a} \frac{p(z)}{\frac{q(z)}{z-a}} = \lim_{z \to a} \frac{p(z)}{\frac{q(z) - (a)}{z-a}} = \frac{p(a)}{q'(a)}$ where I used the fact that $a$ is a pole, which says that $q(a) = 0$.