Package org.apache.commons.httpclient

Examples of org.apache.commons.httpclient.Header


    super(inS);
    fGetMethod = getMethod;
    fMonitor = monitor;

    /* Keep some important Headers */
    Header headerLastModified = getMethod.getResponseHeader(HEADER_RESPONSE_LAST_MODIFIED);
    if (headerLastModified != null)
      setIfModifiedSince(headerLastModified.getValue());

    Header headerETag = getMethod.getResponseHeader(HEADER_RESPONSE_ETAG);
    if (headerETag != null)
      setIfNoneMatch(headerETag.getValue());
  }
View Full Code Here


      try
      {
         deploy("staticarray.sar");
         // Set the static array value to a non-default from war1
         HttpMethodBase request = HttpUtils.accessURL(url);
         Header errors = request.getResponseHeader("X-Error");
         log.info("war1 X-Error: "+errors);
         assertTrue("war1 X-Error("+errors+") is null", errors == null);
         // Validate that war2 sees the changed values
         url = new URL(baseURL+"staticarray-web2/validate.jsp"
               + "?Sequencer.info.expected=1,2,3,4,5,6,7,8,9,10");
View Full Code Here

        log.error("Unexpected HTTP Status::" + method.getStatusLine().toString());
      }
    } catch (Exception e) {
      log.error("Unexpected exception trying to get flexions!", e);
    }
    Header responseHeader = method.getResponseHeader("Content-Type");
    if (responseHeader == null) {
      // error
      log.error("URL not found!");
    }
    HttpRequestMediaResource mr = new HttpRequestMediaResource(method);
View Full Code Here

  /**
   * @see org.olat.core.gui.media.MediaResource#getContentType()
   */
  public String getContentType() {
    Header h = meth.getResponseHeader("Content-Type");
    return h == null ? "" : h.getValue();

  }
View Full Code Here

  /**
   * @see org.olat.core.gui.media.MediaResource#getSize()
   */
  public Long getSize() {
    Header h = meth.getResponseHeader("Content-Length");
    return h == null ? null : new Long(h.getValue());
  }
View Full Code Here

  /**
   * @see org.olat.core.gui.media.MediaResource#getLastModified()
   */
  public Long getLastModified() {
    Header h = meth.getResponseHeader("Last-Modified");
    if (h != null) {
      try {
        DateFormat df = new SimpleDateFormat("EEE, d MMM yyyy HH:mm:ss z");
        Date d = df.parse(h.getValue());
        long l = d.getTime();
        return new Long(l);
      } catch (ParseException e) {
        //
      }
View Full Code Here

   * @see org.olat.core.gui.media.MediaResource#prepare(javax.servlet.http.HttpServletResponse)
   */
  public void prepare(HttpServletResponse hres) {
    //deliver content-disposition if available to forward this information
    //e.g. when someone is delivering generated files and sets the header himself
    Header h = meth.getResponseHeader("Content-Disposition");
    if (h == null) return;
    if (h.getValue().toLowerCase().contains("filename")) {
      hres.setHeader("Content-Disposition", h.getValue());
    } else {
      hres.setHeader("Content-Disposition", "filename=" + h.getValue());
    }
   
  }
View Full Code Here

      indexGet.addRequestHeader(headerId, "jduke");
      httpConn.getState().addCookie(cookie);
      int responseCode = httpConn.executeMethod(indexGet);
      String response = indexGet.getStatusText();
      log.debug("Response from " + usecase + " case:"+response);
      Header jex = indexGet.getResponseHeader("X-JException");
      log.debug("Saw X-JException, "+jex);
      assertNull("X-JException == null", jex);
      assertTrue("Get OK("+responseCode+")", responseCode == HttpURLConnection.HTTP_OK);
   }
View Full Code Here

      String response = formPost.getStatusText();
      log.debug("responseCode="+responseCode+", response="+response);
      assertTrue("Saw HTTP_MOVED_TEMP", responseCode == HttpURLConnection.HTTP_MOVED_TEMP);

      //  Follow the redirect to the SecureServlet
      Header location = formPost.getResponseHeader("Location");
      String indexURI = location.getValue();
      GetMethod war1Index = new GetMethod(indexURI);
      responseCode = httpConn.executeMethod(war1Index.getHostConfiguration(),
            war1Index, state);
      response = war1Index.getStatusText();
      log.debug("responseCode="+responseCode+", response="+response);
View Full Code Here

      // fill in the login form and submit it
      PostMethod postMethod = new PostMethod(this.testAppBaseURL + "j_security_check");
      postMethod.addRequestHeader("Referer", this.testAppBaseURL + "restricted/login.html");
      postMethod.addParameter("j_username", "jduke");
      postMethod.addParameter("j_password", "theduke");
      Header location = null;
      try
      {
         int responseCode = this.httpClient.executeMethod(postMethod.getHostConfiguration(), postMethod, state);
         log.debug("responseCode=" + responseCode + ", response=" + postMethod.getStatusText());
         // check the response code received and the presence of a location header in the response
         assertTrue("Unexpected response code received: " + responseCode,
               responseCode == HttpURLConnection.HTTP_MOVED_TEMP);
         location = postMethod.getResponseHeader("Location");
         assertNotNull("Location header not found in response", location);
      }
      finally
      {
         postMethod.releaseConnection();
      }

      // follow the redirect as defined by the location header
      String indexURI = location.getValue();
      getMethod = new GetMethod(indexURI);
      try
      {
         int responseCode = this.httpClient.executeMethod(getMethod.getHostConfiguration(), getMethod, state);
         log.debug("responseCode=" + responseCode + ", response=" + getMethod.getStatusText());
View Full Code Here

TOP

Related Classes of org.apache.commons.httpclient.Header

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.