Package freenet.support.api

Examples of freenet.support.api.HTTPRequest


        URI refererURI = new URI(URIPreEncoder.encode(referer));
        String path = refererURI.getPath();
        while(path.startsWith("/")) path = path.substring(1);
        if("".equals(path)) return "/";
        FreenetURI furi = new FreenetURI(path);
        HTTPRequest req = new HTTPRequestImpl(refererURI, "GET");
        String type = req.getParam("type");
        referer = "/" + furi.toString();
        if(type != null && type.length() > 0)
          referer += "?type=" + type;
      } catch (MalformedURLException e) {
        referer = "/";
View Full Code Here


        redirectTarget = steps.get(currentStep).postStep(request);

        //Opennet step can change the persisted value for opennet.
        if (currentStep == WIZARD_STEP.OPENNET) {
          try {
            HTTPRequest newRequest = new HTTPRequestImpl(new URI(
                    stepURL(redirectTarget)), "GET");
            //Only continue if a value for opennet has been selected.
            if (newRequest.isPartSet("opennet")) {
              redirectTarget = WIZARD_STEP.SECURITY_NETWORK.name();
              persistFields = new PersistFields(persistFields.preset, newRequest);
            }
          } catch (URISyntaxException e) {
            Logger.error(this, "Unexpected invalid query string from OPENNET step! "+e, e);
View Full Code Here

      if(logMINOR) Logger.minor(this, "Failed to parse URI: "+e1);
      throw new CommentException(l10n("couldNotParseURIWithError", "error", e1.getMessage()));
    }
    String path = uri.getPath();
   
    HTTPRequest req = new HTTPRequestImpl(uri, "GET");
    if (path != null) {
      if (path.equals("/") && req.isParameterSet("newbookmark") && !forBaseHref) {
        // allow links to the root to add bookmarks
        String bookmark_key = req.getParam("newbookmark");
        String bookmark_desc = req.getParam("desc");
        String bookmark_activelink = req.getParam("hasAnActivelink", "");

        try {
          FreenetURI furi = new FreenetURI(bookmark_key);
          bookmark_key = furi.toString();
          bookmark_desc = URLEncoder.encode(bookmark_desc, "UTF-8");
View Full Code Here

  }

  private String processURI(FreenetURI furi, URI uri, String overrideType, boolean noRelative, boolean inline) {
    // Valid Freenet URI, allow it
    // Now what about the queries?
    HTTPRequest req = new HTTPRequestImpl(uri, "GET");
    if(cb != null) cb.foundURI(furi);
    if(cb != null) cb.foundURI(furi, inline);
    return finishProcess(req, overrideType, '/' + furi.toString(false, false), uri, noRelative);
  }
View Full Code Here

  public void testBookmarkingExistingPost() throws URISyntaxException {
    /* create mocks. */
    Core core = mock(Core.class);
    WebInterface webInterface = mock(WebInterface.class);
    when(webInterface.getCore()).thenReturn(core);
    HTTPRequest httpRequest = new HTTPRequestImpl(new URI("/ajax/bookmark.ajax?post=abc"), "GET");
    FreenetRequest request = mock(FreenetRequest.class);
    when(request.getHttpRequest()).thenReturn(httpRequest);

    /* create JSON page. */
    BookmarkAjaxPage bookmarkAjaxPage = new BookmarkAjaxPage(webInterface);
View Full Code Here

  public void testBookmarkingMissingPost() throws URISyntaxException {
    /* create mocks. */
    Core core = mock(Core.class);
    WebInterface webInterface = mock(WebInterface.class);
    when(webInterface.getCore()).thenReturn(core);
    HTTPRequest httpRequest = new HTTPRequestImpl(new URI("/ajax/bookmark.ajax"), "GET");
    FreenetRequest request = mock(FreenetRequest.class);
    when(request.getHttpRequest()).thenReturn(httpRequest);

    /* create JSON page. */
    BookmarkAjaxPage bookmarkAjaxPage = new BookmarkAjaxPage(webInterface);
View Full Code Here

   * {@inheritDoc}
   */
  @Override
  protected String getRedirectTarget(FreenetRequest request) {
    if (requiresLogin() && (getCurrentSone(request.getToadletContext(), false) == null)) {
      HTTPRequest httpRequest = request.getHttpRequest();
      String originalUrl = httpRequest.getPath();
      if (httpRequest.hasParameters()) {
        StringBuilder requestParameters = new StringBuilder();
        for (String parameterName : httpRequest.getParameterNames()) {
          if (requestParameters.length() > 0) {
            requestParameters.append("%26");
          }
          String[] parameterValues = httpRequest.getMultipleParam(parameterName);
          for (String parameterValue : parameterValues) {
            try {
              requestParameters.append(URLEncoder.encode(parameterName, "UTF-8")).append("%3d").append(URLEncoder.encode(parameterValue, "UTF-8"));
            } catch (UnsupportedEncodingException uee1) {
              /* A JVM without UTF-8? I don’t think so. */
 
View Full Code Here

  public Object get(TemplateContext templateContext, Object object, String member) {
    Object parentValue = super.get(templateContext, object, member);
    if (parentValue != null) {
      return parentValue;
    }
    HTTPRequest httpRequest = (HTTPRequest) object;
    return httpRequest.getHeader(member);
  }
View Full Code Here

TOP

Related Classes of freenet.support.api.HTTPRequest

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.