Definite Integral Problem using substitution $t=\tan(x/2)$ Solve $$ \int_0^\pi \frac {x} {1+\sin x} dx $$ using $\sin x = \frac {2\tan(x/2)} {1+\tan^2(x/2)}$ and the substitution $t = \tan(x/2)$.
I tried doing this but I got to a point where my integral limits were $0$ to $\infty
$. This happened when I substituted for $\tan(x/2)$
Is there a way of doing this using this substitution only?
And also why does this happen?
UPDATE: What I did -
$$ I = \int_0^\pi \frac {\pi-x} {1+\sin x} dx = \int_0^\pi \frac {\pi} {1+ \sin x} dx - I$$
Using $\sin x = \frac {2\tan(x/2)} {1+\tan^2(x/2)}$
$$ $$
$$ 2I = \int_0^\pi \frac {\pi} {1+\sin x} dx = \pi\int_0^\pi \frac {\sec^2(x/2)} {1+ \tan^2(x/2)+2 \tan(x/2)} dx$$
Now if there were no limits, this could've been solved easily by $t = \tan x$.
But I can't do that because if I did, the limits would become $0$ to $\infty$.
A way to solve this would be multiplying and dividing by $1+ \sin x$ but I don't want to do that. I want to use $t=\tan x$

If we must solve the problem with the suggested substitution, the integral becomes $\int_0^\infty\frac{4\arctan t dt}{(1+t)^2}$. The identity $\int_0^\infty f(t)dt=\int_0^1\left(f(t)+\tfrac{1}{t^2}f\left(\tfrac{1}{t}\right)\right)dt$ changes this to $\int_0^1\frac{2\pi dt}{(1+t)^2}=\pi$.
