# Contour Integration to Evaluate Improper Integral

I am working on the problem above and have, for part a, that $$D=\{z \in \mathbb{C} | 0< \Re(z) < 1\}$$. What I'm working on now is part b.

My attempt so far: I have set up a rectangular contour, $$\Gamma$$, with its base sitting on the real axis, going from -R to R, and with a height of $$2\pi i$$. Using the residue theorem, along with the fact that $$e^{pz}/(1+e^z)$$ has a pole of order 1 at $$z=\pi i$$, I get that $$\int_{\Gamma} \frac{e^{pz}}{1+e^z}dz = 2\pi i (-e^{p\pi i})$$ But this must be equal to the sum of the four separate integrals over the four sides of the rectangle. Using the ML inequality we quickly get that as $$R\rightarrow \infty$$, the contour integrals over the two vertical sides of the rectangular contour go to zero. So it looks like I'm left with: $$\int_{\Gamma} \frac{e^{pz}}{1+e^z}dz = 2\pi i (-e^{p\pi i}) = \lim_{R\to\infty} \Bigg(\int_{-R}^{R} \frac{e^{px}}{1+e^x}dx + \int_{R+2\pi i}^{-R + 2\pi i} \frac{e^{pz}}{1+e^z}dx\Bigg)$$ Using the parametrization $$\gamma(t)=2\pi i + t$$, where $$t \in [-R,R]$$, I get that $$\int_{R+2\pi i}^{-R + 2\pi i} \frac{e^{pz}} {1+e^z}dz = -\int_{-R}^{R} \frac{e^{p\gamma(t)}}{1+e^{\gamma(t)}}dt = -e^{p(2\pi i)}\int_{-R}^{R} \frac{e^{px}}{1+e^x}dx$$ Finally, equating what I got from the Residue Theorem to the sum of the individual contour integrals, I get: $$\int_{-\infty}^{\infty} \frac{e^{px}}{1+e^x}dx = \frac{2\pi i (-e^{p\pi i})}{1-e^{p(2\pi i)}}$$ However, this is clearly not right as this will yield non-real answers depending on the value of p. Where did I go wrong here?

Note that for $$0<\text{Re}(p)<1$$, we have
\begin{align} \int_{-\infty}^\infty\frac{e^{px}}{1+e^x}\,dx &=2\pi i \left(\frac{-e^{i\pi p}}{1-e^{i2\pi p}}\right)\\\\ &=\frac{2\pi i}{e^{i\pi p}-e^{-i\pi p}}\\\\ &=\frac{\pi}{\sin(\pi p)} \end{align}
which is real valued when $$p$$ is a real number with $$0.