Tabnine Logo
HttpRequest.addHeader
Code IndexAdd Tabnine to your IDE (free)

How to use
addHeader
method
in
org.apache.shindig.gadgets.http.HttpRequest

Best Java code snippets using org.apache.shindig.gadgets.http.HttpRequest.addHeader (Showing top 20 results out of 315)

origin: com.lmco.shindig/shindig-gadgets

/**
 * Construct a new request for the given uri.
 */
public HttpRequest(Uri uri) {
 this.uri = uri;
 authType = AuthType.NONE;
 addHeader(DOS_PREVENTION_HEADER, "on");
}
origin: org.apache.shindig/shindig-gadgets

/**
 * Construct a new request for the given uri.
 */
public HttpRequest(Uri uri) {
 this.uri = uri;
 authType = AuthType.NONE;
 addHeader(DOS_PREVENTION_HEADER, "on");
}
origin: com.lmco.shindig/shindig-gadgets

/**
 * Adds an entire map of headers to the request.
 */
public HttpRequest addHeaders(Map<String, String> headers) {
 for (Map.Entry<String, String> entry : headers.entrySet()) {
  addHeader(entry.getKey(), entry.getValue());
 }
 return this;
}
origin: org.apache.shindig/shindig-gadgets

/**
 * Adds an entire map of headers to the request.
 */
public HttpRequest addHeaders(Map<String, String> headers) {
 for (Map.Entry<String, String> entry : headers.entrySet()) {
  addHeader(entry.getKey(), entry.getValue());
 }
 return this;
}
origin: org.apache.shindig/shindig-gadgets

@Test
public void getHeaders() throws Exception {
 HttpRequest request = new HttpRequest(DEFAULT_URI)
   .addHeader(TEST_HEADER_KEY, TEST_HEADER_VALUE)
   .addHeader(TEST_HEADER_KEY, TEST_HEADER_VALUE2);
 Collection<String> expected = Arrays.asList(TEST_HEADER_VALUE, TEST_HEADER_VALUE2);
 assertTrue(request.getHeaders(TEST_HEADER_KEY).containsAll(expected));
}
origin: org.apache.shindig/shindig-gadgets

private void expectPostAndReturnBody(AuthType authType, String postData, String response)
  throws Exception {
 HttpRequest req = new HttpRequest(REQUEST_URL).setMethod("POST")
   .setPostBody(postData.getBytes("UTF-8"))
   .setAuthType(authType)
   .addHeader("Content-Type", "application/x-www-form-urlencoded");
 expect(pipeline.execute(req)).andReturn(new HttpResponse(response));
 expect(request.getParameter(MakeRequestHandler.METHOD_PARAM)).andReturn("POST");
 expect(request.getParameter(MakeRequestHandler.POST_DATA_PARAM))
   .andReturn(postData);
}
origin: com.lmco.shindig/shindig-gadgets

private void expectPostAndReturnBody(AuthType authType, String postData, String response)
  throws Exception {
 HttpRequest req = new HttpRequest(REQUEST_URL).setMethod("POST")
   .setPostBody(REQUEST_BODY.getBytes("UTF-8"))
   .setAuthType(authType)
   .addHeader("Content-Type", "application/x-www-form-urlencoded");
 expect(pipeline.execute(req)).andReturn(new HttpResponse(response));
 expect(request.getParameter(MakeRequestHandler.METHOD_PARAM)).andReturn("POST");
 expect(request.getParameter(MakeRequestHandler.POST_DATA_PARAM))
   .andReturn(REQUEST_BODY);
}
origin: org.wso2.org.apache.shindig/shindig-gadgets

private void expectPostAndReturnBody(AuthType authType, String postData, String response)
  throws Exception {
 HttpRequest req = new HttpRequest(REQUEST_URL).setMethod("POST")
   .setPostBody(postData.getBytes("UTF-8"))
   .setAuthType(authType)
   .addHeader("Content-Type", "application/x-www-form-urlencoded");
 expect(pipeline.execute(req)).andReturn(new HttpResponse(response));
 expect(request.getParameter(MakeRequestHandler.METHOD_PARAM)).andReturn("POST");
 expect(request.getParameter(MakeRequestHandler.POST_DATA_PARAM))
   .andReturn(postData);
}
origin: org.wso2.org.apache.shindig/shindig-gadgets

@Test
public void getHeader() throws Exception {
 Map<String, List<String>> headers = Maps.newHashMap();
 headers.put(TEST_HEADER_KEY, Arrays.asList(TEST_HEADER_VALUE));
 HttpRequest request = new HttpRequest(DEFAULT_URI)
   .addHeader(TEST_HEADER_KEY, TEST_HEADER_VALUE);
 assertEquals(TEST_HEADER_VALUE, request.getHeader(TEST_HEADER_KEY));
}
origin: com.lmco.shindig/shindig-gadgets

@Test
public void getHeader() throws Exception {
 Map<String, List<String>> headers = Maps.newHashMap();
 headers.put(TEST_HEADER_KEY, Arrays.asList(TEST_HEADER_VALUE));
 HttpRequest request = new HttpRequest(DEFAULT_URI)
   .addHeader(TEST_HEADER_KEY, TEST_HEADER_VALUE);
 assertEquals(TEST_HEADER_VALUE, request.getHeader(TEST_HEADER_KEY));
}
origin: org.apache.shindig/shindig-gadgets

@Test
public void getHeader() throws Exception {
 Map<String, List<String>> headers = Maps.newHashMap();
 headers.put(TEST_HEADER_KEY, Arrays.asList(TEST_HEADER_VALUE));
 HttpRequest request = new HttpRequest(DEFAULT_URI)
   .addHeader(TEST_HEADER_KEY, TEST_HEADER_VALUE);
 assertEquals(TEST_HEADER_VALUE, request.getHeader(TEST_HEADER_KEY));
}
origin: org.apache.shindig/shindig-gadgets

@Test
public void contentTypeExtraction() throws Exception {
 HttpRequest request = new HttpRequest(DEFAULT_URI)
   .addHeader("Content-Type", CONTENT_TYPE);
 assertEquals(CONTENT_TYPE, request.getContentType());
}
origin: com.lmco.shindig/shindig-gadgets

@Test
public void contentTypeExtraction() throws Exception {
 HttpRequest request = new HttpRequest(DEFAULT_URI)
   .addHeader("Content-Type", CONTENT_TYPE);
 assertEquals(CONTENT_TYPE, request.getContentType());
}
origin: org.apache.shindig/shindig-gadgets

@Test
public void getResponseUsingMethodOverride() {
 HttpRequest request = new HttpRequest(DEFAULT_URI)
   .setMethod("POST")
   .addHeader("X-Method-Override", "GET");
 String key = cache.createKey(request);
 HttpResponse response = new HttpResponse("result");
 cache.map.put(key, response);
 assertEquals(response, cache.getResponse(request));
 extendedStrictNoCacheTtlCache.map.put(key, response);
 assertEquals(response, extendedStrictNoCacheTtlCache.getResponse(request));
}
origin: org.wso2.org.apache.shindig/shindig-gadgets

@Test
public void getResponseUsingMethodOverride() {
 HttpRequest request = new HttpRequest(DEFAULT_URI)
   .setMethod("POST")
   .addHeader("X-Method-Override", "GET");
 String key = cache.createKey(request);
 HttpResponse response = new HttpResponse("result");
 cache.map.put(key, response);
 assertEquals(response, cache.getResponse(request));
 extendedStrictNoCacheTtlCache.map.put(key, response);
 assertEquals(response, extendedStrictNoCacheTtlCache.getResponse(request));
}
origin: com.lmco.shindig/shindig-gadgets

@Test
public void getResponseUsingMethodOverride() {
 HttpRequest request = new HttpRequest(DEFAULT_URI)
   .setMethod("POST")
   .addHeader("X-Method-Override", "GET");
 String key = cache.createKey(request);
 HttpResponse response = new HttpResponse("result");
 cache.map.put(key, response);
 assertEquals(response, cache.getResponse(request));
}
origin: org.apache.shindig/shindig-gadgets

@Test
public void addResponseUsingMethodOverride() {
 HttpRequest request = new HttpRequest(DEFAULT_URI)
   .setMethod("POST")
   .addHeader("X-Method-Override", "GET");
 HttpResponse response = new HttpResponse("normal");
 String key = cache.createKey(request);
 assertNotNull(cache.addResponse(request, response));
 assertEquals(response, cache.map.get(key));
 assertNotNull(extendedStrictNoCacheTtlCache.addResponse(request, response));
 assertEquals(response, extendedStrictNoCacheTtlCache.map.get(key));
}
origin: org.apache.shindig/shindig-gadgets

@Test public void testHugeBody() throws Exception {
 byte[] body = new byte[1024*1024]; // 1 MB
 for (int i=0; i < body.length; ++i) {
  body[i] = (byte)i;
 }
 HttpRequest request = new HttpRequest(BASE_URL)
   .setMethod("POST")
   .setPostBody(body)
   .addHeader("content-type", "application/octet-stream");
 HttpResponse response = fetcher.fetch(request);
 assertEquals("POST", response.getHeader("x-method"));
 ArrayAssert.assertEquals(body, response.getResponseAsBytes());
}
origin: org.wso2.org.apache.shindig/shindig-gadgets

@Test public void testPost_withBody() throws Exception {
 byte[] body = new byte[5000];
 for (int i=0; i < body.length; ++i) {
  body[i] = (byte)(i % 255);
 }
 HttpRequest request = new HttpRequest(BASE_URL)
   .setMethod("POST")
   .setPostBody(body)
   .addHeader("content-type", "application/octet-stream");
 HttpResponse response = fetcher.fetch(request);
 assertEquals("POST", response.getHeader("x-method"));
 ArrayAssert.assertEquals(body, response.getResponseAsBytes());
}
origin: org.apache.shindig/shindig-gadgets

@Test public void testPut_withBody() throws Exception {
 byte[] body = new byte[5000];
 for (int i=0; i < body.length; ++i) {
  body[i] = (byte)i;
 }
 HttpRequest request = new HttpRequest(BASE_URL)
   .setMethod("PUT")
   .setPostBody(body)
   .addHeader("content-type", "application/octet-stream");
 HttpResponse response = fetcher.fetch(request);
 assertEquals("PUT", response.getHeader("x-method"));
 ArrayAssert.assertEquals(body, response.getResponseAsBytes());
}
org.apache.shindig.gadgets.httpHttpRequestaddHeader

Javadoc

Add a single header to the request. If a value for the given name is already set, a second value is added. If you wish to overwrite any possible values for a header, use #setHeader(String,String).

Popular methods of HttpRequest

  • <init>
    Clone an existing HttpRequest.
  • getAuthType
  • getCacheTtl
  • getContainer
  • getFollowRedirects
  • getGadget
  • getHeader
  • getHeaders
  • getIgnoreCache
  • getMethod
  • getOAuthArguments
  • getParam
  • getOAuthArguments,
  • getParam,
  • getParamAsInteger,
  • getPostBody,
  • getPostBodyAsString,
  • getPostBodyLength,
  • getRewriteMimeType,
  • getSecurityToken,
  • getUri

Popular in Java

  • Finding current android device location
  • getExternalFilesDir (Context)
  • getSharedPreferences (Context)
  • addToBackStack (FragmentTransaction)
  • ObjectMapper (com.fasterxml.jackson.databind)
    ObjectMapper provides functionality for reading and writing JSON, either to and from basic POJOs (Pl
  • System (java.lang)
    Provides access to system-related information and resources including standard input and output. Ena
  • BigDecimal (java.math)
    An immutable arbitrary-precision signed decimal.A value is represented by an arbitrary-precision "un
  • BlockingQueue (java.util.concurrent)
    A java.util.Queue that additionally supports operations that wait for the queue to become non-empty
  • Executors (java.util.concurrent)
    Factory and utility methods for Executor, ExecutorService, ScheduledExecutorService, ThreadFactory,
  • Loader (org.hibernate.loader)
    Abstract superclass of object loading (and querying) strategies. This class implements useful common
  • Top Vim plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now