-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
pavel.stastny
committed
Jul 9, 2020
1 parent
82a48a6
commit b1063b2
Showing
3 changed files
with
69 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
rest/src/main/java/cz/incad/kramerius/rest/api/k5/client/debug/HTTPHeaders.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package cz.incad.kramerius.rest.api.k5.client.debug; | ||
|
||
import com.google.inject.Inject; | ||
import com.google.inject.Provider; | ||
import cz.incad.kramerius.ObjectPidsPath; | ||
import cz.incad.kramerius.rest.api.exceptions.ActionNotAllowedXML; | ||
import cz.incad.kramerius.rest.api.k5.client.item.exceptions.PIDNotFound; | ||
import cz.incad.kramerius.security.SecuredActions; | ||
import cz.incad.kramerius.service.ReplicateException; | ||
import cz.incad.kramerius.service.replication.FormatType; | ||
import cz.incad.kramerius.utils.IOUtils; | ||
|
||
import javax.servlet.http.HttpServletRequest; | ||
import javax.ws.rs.*; | ||
import javax.ws.rs.core.MediaType; | ||
import javax.ws.rs.core.Response; | ||
import javax.ws.rs.core.StreamingOutput; | ||
import java.io.ByteArrayInputStream; | ||
import java.io.IOException; | ||
import java.io.OutputStream; | ||
import java.io.StringWriter; | ||
import java.util.Enumeration; | ||
import java.util.Properties; | ||
|
||
@Path("/v5.0/debug") | ||
public class HTTPHeaders { | ||
|
||
@Inject | ||
Provider<HttpServletRequest> requestProvider; | ||
|
||
@GET | ||
@Path("headers") | ||
@Produces({ MediaType.TEXT_PLAIN + ";charset=utf-8" }) | ||
public String headers() throws IOException { | ||
Properties properties = new Properties(); | ||
HttpServletRequest httpServletRequest = requestProvider.get(); | ||
Enumeration headerNames = httpServletRequest.getHeaderNames(); | ||
while (headerNames.hasMoreElements()) { | ||
Object o = headerNames.nextElement(); | ||
String val = httpServletRequest.getHeader(o.toString()); | ||
properties.put(o, val); | ||
} | ||
StringWriter writer = new StringWriter(); | ||
properties.store(writer,"HTTP Request headers"); | ||
return writer.toString(); | ||
} | ||
|
||
} |