In this post two solutions have been proposed to give a meaning to the integral
$$I=\int_{0}^{+\infty} \frac{x\tan(x)}{1+x^2}\,dx\tag{*}$$
The main problem with this integral is obviously the occurence of poles of the integrand at $x=\pi(n+\frac{1}{2})$, i.e. where the $\cos$ vanishes and the integrand diverges. The solution to get rid of the poles was provided within the concept of the (Cauchy) principal value.
Here we ask for the value of the simpler integral with the same poles
$$i=\int_{0}^{+\infty} \frac{\sec(x)}{1+x^2}\,dx\tag{1}$$
Solution attempts: The first idea is to split the integration region into intervals of length $\pi$ from $\pi n$ to $\pi(n+1)$, $n=0,1,2,...$ take the pricipal value of the integral of each summand
$$i_{n} =PV\int_{\pi n}^{\pi(n+1)} \frac{\sec(x)}{1+x^2}\,dx\tag{2}$$
and sum them up
$$i = \sum_{n=0}^{+\infty} i_{n}\tag{3}$$
Possibly equivalently we could shift the integration contour up from the real axis by a small amount $\epsilon$ and use residues.
Task:
calculate the values of the integral by both ways and show if they are equvalent of not.
Bonus question:
Calculate the integral
$$f=\int_{0}^{+\infty} \frac{x \sec(x)}{1+x^2}\,dx\tag{4}$$