Improper integral of $\int_0^\infty \frac{dx}{(x^2+{\pi}^2)\cosh(x)}$

here is a simple approach, but only with real function method

$$\int_{0}^{\infty} {e^{-bt}\cos(at)\,\mathrm{d}t} = \frac{b}{a^2+b^2}$$

we write

$$\begin{aligned} \int_{0}^{\infty} \frac{\mathrm{d}x}{(x^2+\pi^2)\cosh x} & = \frac1{\pi} \int_{0}^{\infty} \left(\int_{0}^{\infty} {e^{-\pi t}\cos(tx)\,\mathrm{d}t}\right) \frac{\mathrm{d}x}{\cosh x}\\ & = \frac1{\pi} \int_{0}^{\infty} \left(e^{-\pi t} \int_{0}^{\infty} {\frac{\cos(tx)}{\cosh x} \mathrm{d}x} \right) \mathrm{d}t\\ & = \frac1{2} \int_{0}^{\infty} e^{-\pi t} \operatorname{sech}\left(\frac{\pi t}{2}\right) \mathrm{d}t = \int_{0}^{\infty} \frac{e^{-\pi t}}{e^{\pi t/2} + e^{-\pi t/2}} \mathrm{d}t\\ (\text{let } z=e^{-\pi t/2}) \quad & = \frac2{\pi} \int_{0}^{1} \frac{z^2}{1+z^2} \mathrm{d}z = \frac2{\pi}-\frac1{2} \end{aligned}$$

where recalling this famous integral

$$\int_{0}^{\infty} {\frac{\cos(\alpha x)}{\cosh(\beta x)}\mathrm{d}x} = \frac{\pi}{2\beta} \operatorname{sech}\left(\frac{\pi\alpha}{2\beta}\right)$$


In fact, I found that decomposition into simple fractions solves the problem! $$ I=\int_0^\infty \frac{dx}{(x^2+{\pi}^2)\cosh(x)}=\int_{-\infty}^\infty dx\frac{e^{x}}{(x^2+{\pi}^2)(e^{2x}+1)}= \\ \frac{1}{2\pi i}\int_{-\infty}^\infty dx\frac{e^{x}}{(x-i\pi)(e^{2x}+1)}-\frac{1}{2\pi i}\int_{-\infty}^\infty dx\frac{e^{x}}{(x+i\pi)(e^{2x}+1)} $$ After the obvious substitution it's equal to $$ I=-\frac{1}{2\pi i}\int_{-\infty-\pi i}^{\infty-\pi i} dx\frac{e^{x}}{x(e^{2x}+1)}+\frac{1}{2\pi i}\int_{-\infty+\pi i}^{\infty+\pi i} dx\frac{e^{x}}{x(e^{2x}+1)} $$ Now if we take the contour: $-R+\pi i \to R+\pi i \to R - \pi i \to -R - \pi i$, then it's clear, that $$I = -\sum\limits_{k} Res[f(z),z_k]$$ Where $f(z)=\frac{e^{z}dz}{z(e^{2z}+1)}$ and $z_k \in[-\frac{\pi i}{2}, \ 0,\ \frac{\pi i}{2}]$.

Thus the answer follows: $I=\frac{2}{\pi}-\frac{1}{2}$.