Java Code Examples for org.apache.olingo.server.api.ODataRequest#setProtocol()

The following examples show how to use org.apache.olingo.server.api.ODataRequest#setProtocol() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ODataNettyHandlerImpl.java    From olingo-odata4 with Apache License 2.0 6 votes vote down vote up
/**
 * Extract the information part of Netty Request and fill OData Request
 * @param odRequest
 * @param httpRequest
 * @param split
 * @param contextPath
 * @return
 * @throws ODataLibraryException
 */
private ODataRequest fillODataRequest(final ODataRequest odRequest, final HttpRequest httpRequest,
     final int split, final String contextPath) throws ODataLibraryException {
   final int requestHandle = debugger.startRuntimeMeasurement("ODataHttpHandlerImpl", "fillODataRequest");
   try {
   	ByteBuf byteBuf = ((HttpContent)httpRequest).content();
   	ByteBufInputStream inputStream = new ByteBufInputStream(byteBuf);
     odRequest.setBody(inputStream);
     
     odRequest.setProtocol(httpRequest.protocolVersion().text());
     odRequest.setMethod(extractMethod(httpRequest));
     int innerHandle = debugger.startRuntimeMeasurement("ODataNettyHandlerImpl", "copyHeaders");
     copyHeaders(odRequest, httpRequest);
     debugger.stopRuntimeMeasurement(innerHandle);
     innerHandle = debugger.startRuntimeMeasurement("ODataNettyHandlerImpl", "fillUriInformation");
     fillUriInformationFromHttpRequest(odRequest, httpRequest, split, contextPath);
     debugger.stopRuntimeMeasurement(innerHandle);

     return odRequest;
   } finally {
     debugger.stopRuntimeMeasurement(requestHandle);
   }
 }
 
Example 2
Source File: ODataHttpHandlerImpl.java    From olingo-odata4 with Apache License 2.0 6 votes vote down vote up
private ODataRequest fillODataRequest(final ODataRequest odRequest, final HttpServletRequest httpRequest,
    final int split) throws ODataLibraryException {
  final int requestHandle = debugger.startRuntimeMeasurement("ODataHttpHandlerImpl", "fillODataRequest");
  try {
    odRequest.setBody(httpRequest.getInputStream());
    odRequest.setProtocol(httpRequest.getProtocol());
    odRequest.setMethod(extractMethod(httpRequest));
    int innerHandle = debugger.startRuntimeMeasurement("ODataHttpHandlerImpl", "copyHeaders");
    copyHeaders(odRequest, httpRequest);
    debugger.stopRuntimeMeasurement(innerHandle);
    innerHandle = debugger.startRuntimeMeasurement("ODataHttpHandlerImpl", "fillUriInformation");
    fillUriInformation(odRequest, httpRequest, split);
    debugger.stopRuntimeMeasurement(innerHandle);

    return odRequest;
  } catch (final IOException e) {
    throw new DeserializerException("An I/O exception occurred.", e,
        DeserializerException.MessageKeys.IO_EXCEPTION);
  } finally {
    debugger.stopRuntimeMeasurement(requestHandle);
  }
}
 
Example 3
Source File: DebugTabRequestTest.java    From olingo-odata4 with Apache License 2.0 5 votes vote down vote up
@Test
public void singleHeaderValue() throws Exception {
  String expectedJson =
      "{\"method\":\"GET\",\"uri\":\"def&\",\"protocol\":\"def&\",\"headers\":{\"HeaderName\":\"Value1\"}}";
  String expectedHtml = "<h2>Request Method</h2>\n"
      + "<p>GET</p>\n"
      + "<h2>Request URI</h2>\n"
      + "<p>def&amp;</p>\n"
      + "<h2>Request Protocol</h2>\n"
      + "<p>def&amp;</p>\n"
      + "<h2>Request Headers</h2>\n"
      + "<table>\n"
      + "<thead>\n"
      + "<tr><th class=\"name\">Name</th><th class=\"value\">Value</th></tr>\n"
      + "</thead>\n"
      + "<tbody>\n"
      + "<tr><td class=\"name\">HeaderName</td><td class=\"value\">Value1</td></tr>\n"
      + "</tbody>\n"
      + "</table>\n";

  ODataRequest oDataRequest = new ODataRequest();
  oDataRequest.setMethod(HttpMethod.GET);
  oDataRequest.setRawRequestUri("def&");
  oDataRequest.setProtocol("def&");
  List<String> headerValues = new ArrayList<String>();
  headerValues.add("Value1");
  oDataRequest.addHeader("HeaderName", headerValues);

  DebugTabRequest requestTab = new DebugTabRequest(oDataRequest);
  assertEquals(expectedJson, createJson(requestTab));
  assertEquals(expectedHtml, createHtml(requestTab));
}
 
Example 4
Source File: DebugTabRequestTest.java    From olingo-odata4 with Apache License 2.0 5 votes vote down vote up
@Test
public void multiHeaderValueResultsInMap() throws Exception {
  String expectedJson = "{\"method\":\"GET\",\"uri\":\"def&\",\"protocol\":\"def&\","
      + "\"headers\":{\"HeaderName\":[\"Value1\",\"Value2\"]}}";
  String expectedHtml = "<h2>Request Method</h2>\n"
      + "<p>GET</p>\n"
      + "<h2>Request URI</h2>\n"
      + "<p>def&amp;</p>\n"
      + "<h2>Request Protocol</h2>\n"
      + "<p>def&amp;</p>\n"
      + "<h2>Request Headers</h2>\n"
      + "<table>\n"
      + "<thead>\n"
      + "<tr><th class=\"name\">Name</th><th class=\"value\">Value</th></tr>\n"
      + "</thead>\n"
      + "<tbody>\n"
      + "<tr><td class=\"name\">HeaderName</td><td class=\"value\">Value1</td></tr>\n"
      + "<tr><td class=\"name\">HeaderName</td><td class=\"value\">Value2</td></tr>\n"
      + "</tbody>\n"
      + "</table>\n";

  ODataRequest oDataRequest = new ODataRequest();
  oDataRequest.setMethod(HttpMethod.GET);
  oDataRequest.setRawRequestUri("def&");
  oDataRequest.setProtocol("def&");
  List<String> headerValues = new ArrayList<String>();
  headerValues.add("Value1");
  headerValues.add("Value2");
  oDataRequest.addHeader("HeaderName", headerValues);

  DebugTabRequest requestTab = new DebugTabRequest(oDataRequest);
  assertEquals(expectedJson, createJson(requestTab));
  assertEquals(expectedHtml, createHtml(requestTab));
}