In a complex analysis class, you’re more likely to come across the integral $$\int_{0}^{\infty} \frac{x^{\alpha}}{1+2x \cos \beta +x^{2}} \, dx = \frac{\pi \sin (\alpha \beta)}{\sin(\alpha \pi) \sin(\beta)}, \quad (-1<\alpha <1, \ 0 < \beta < \pi).$$

See this answer, for example, which uses a semicircle in the upper half-plane that is indented at the origin.

Alternatively, you could also use the keyhole contour that Shashi used.

Also see this question about the peculiar symmetry of this integral when it's written in a slightly different form.

The function on the right is not defined at $\alpha =0$. But you could show separately (by using the same contour or by completing the square) that the value of the integral at $\alpha =0$ is $$\lim_{a \to 0} \frac{\pi \sin (\alpha \beta)}{\sin(\alpha \pi) \sin(\beta)} = \frac{\beta}{\sin \beta}.$$

Now if we assign the function on the right the value $\frac{\beta}{\sin \beta}$ at $\alpha =0$, then right side of the equation is a holomorphic function for $-1 <\operatorname{Re}(\alpha) <1$ with $\beta$ fixed.

And since the integral on the left is absolutely convergent in the strip $-1 < \operatorname{Re}(\alpha) < 1$, we can use a property of the Mellin transform that states that the integral defines an holomorphic function in that strip.

(This is very similar to property of the Laplace transform mentioned here, and can be proved in essentially the same manner.)

So by the identity theorem, the formula holds for $-1 <\operatorname{Re}(\alpha) <1$.

Your integral is the case $\alpha=-ia$ and $\cos(\beta) = \frac{b}{2}$.

If $b\in [0, 2)$, then $\beta$ falls between means $0$ and $\pi$, and we get

$$\begin{align} \int_{0}^{\infty} \frac{x^{-ia}}{x^{2}+bx+1} \, dx &= \frac{\pi \sin\left(-ia \arccos\left(\frac{b}{2} \right)\right)}{\sin(-ia \pi) \sin \left(\arccos \left(\frac{b}{2} \right) \right)} \\ &= \frac{\pi \sinh \left(a \arccos\left(\frac{b}{2} \right) \right)}{\sinh(a \pi)\frac{\sqrt{4-b^{2}}}{2}}. \end{align} $$