Package org.nutz.http

Examples of org.nutz.http.Request


public class UploadTest extends BaseWebappTest {

  @Test
  public void test_upload() throws Throwable {
    Request req = Request.create(getBaseURL()+"/upload/image",METHOD.MULTIPART);
    File f = File.createTempFile("nutz", "data");
    FileWriter fw = new FileWriter(f);
    fw.write("abc");
    fw.flush();
    fw.close();
    req.getParams().put("file", f);
    FilePostSender sender = new FilePostSender(req);
    Response resp = sender.send();
    assertEquals("image&3", resp.getContent());
  }
View Full Code Here


        assertNotNull(resp);
        return resp;
    }

    public Response post(String path, String data) {
        Request req = Request.create(getBaseURL() + path, METHOD.POST);
        req.setData(data);
        resp = Sender.create(req).send();
        assertNotNull(resp);
        return resp;
    }
View Full Code Here

        assertNotNull(resp);
        return resp;
    }

    public Response post(String path, byte[] bytes) {
        Request req = Request.create(getBaseURL() + path, METHOD.POST);
        req.setData(bytes);
        resp = Sender.create(req).send();
        assertNotNull(resp);
        return resp;
    }
View Full Code Here

public class UploadTest extends BaseWebappTest {

    @Test
    public void test_upload() throws Throwable {
        Request req = Request.create(getBaseURL()+"/upload/image",METHOD.POST);
        File f = File.createTempFile("nutz", "data");
        FileWriter fw = new FileWriter(f);
        fw.write("abc");
        fw.flush();
        fw.close();
        req.getParams().put("file", f);
        FilePostSender sender = new FilePostSender(req);
        Response resp = sender.send();
        assertEquals("image&3", resp.getContent());
    }
View Full Code Here

  @SuppressWarnings("unchecked")
  public static Map<String, Object> verify(String audience, String assertion) throws IOException {
    Map<String, Object> params = new HashMap<String, Object>();
    params.put("audience", audience);
    params.put("assertion", assertion);
    Request req = Request.create(VerifyURL, METHOD.POST, params);
    Response resp = Sender.create(req).send();
    if (resp.getStatus() != 200) {
      throw new RuntimeException("server resp code != 200");
    }
    return Json.fromJson(Map.class, Streams.utf8r(resp.getStream()));
View Full Code Here

TOP

Related Classes of org.nutz.http.Request

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.