Let
$$I = \int_{-\infty}^\infty dz\, \frac{e^{kz}}{1+e^z}.$$
Consider the integral $I'$ along the top of the rectangular contour.
We find
$$\begin{eqnarray*}
I' &=& \int_{\infty + 2\pi i}^{-\infty + 2\pi i} dz\, \frac{e^{kz}}{1+e^z} \\
&=& \int_{\infty}^{-\infty} d\zeta\, \frac{e^{k(\zeta+2\pi i)}}{1+e^\zeta}
\hspace{10ex} (\textrm{let } z = \zeta+2\pi i) \\
&=& -e^{2\pi k i} I.
\end{eqnarray*}$$
The argument of the integral along the right side of the rectangle goes like $e^{(k-1)x}$ for $x\gg 0$.
This must be suppressed, so $\mathrm{Re}\, k < 1$.
Likewise, to the left the argument goes like $e^{k x}$ for $x\ll 0$, so $\mathrm{Re}\, k > 0$.
For $0<\mathrm{Re}\, k < 1$, the integrals along the sides of the rectangle vanish.
The integral along the closed rectangular contour is then
$I + I' = (1-e^{2\pi k i})I = 2\pi i \mathrm{Res}_{z=\pi i},$
and so
$$\begin{eqnarray*}
I &=& \frac{1}{1-e^{2\pi k i}}
2\pi i \,\mathrm{Res}_{z=\pi i} \, \frac{e^{kz}}{1+e^z} \\
&=& \frac{1}{1-e^{2\pi k i}} 2\pi i \frac{e^{k\pi i}}{e^{\pi i}}.
\end{eqnarray*}$$
To calculate the residue we use the fact that if $f(z)$ is analytic and $f(z)/g(z)$ has a simple pole at $z_0$ that
$\mathrm{Res}_{z=z_0}f(z)/g(z) = f(z_0)/g'(z_0).$
Therefore, for $0<\mathrm{Re}\, k < 1$,
$$\begin{equation*}
\int_{-\infty}^\infty dz\, \frac{e^{kz}}{1+e^z}
= \frac{\pi}{\sin k\pi}.
\end{equation*}$$