Skip to content

Commit

Permalink
a few tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
purplefox committed Mar 15, 2013
1 parent 79d5905 commit 80961c9
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 15 deletions.
4 changes: 0 additions & 4 deletions src/examples/java/simpleform/SimpleFormServer.java
Expand Up @@ -27,7 +27,6 @@ public class SimpleFormServer extends Verticle {
public void start() {
vertx.createHttpServer().requestHandler(new Handler<HttpServerRequest>() {
public void handle(final HttpServerRequest req) {
System.out.println("uri is " + req.uri);
if (req.uri.equals("/")) {
// Serve the index page
req.response.sendFile("index.html");
Expand All @@ -37,14 +36,11 @@ public void handle(final HttpServerRequest req) {
mpReq.attributeHandler(new Handler<Attribute>() {
@Override
public void handle(Attribute attr) {
System.out.println("Got attr " + attr.name + " : " + attr.value + "\n");

req.response.write("Got attr " + attr.name + " : " + attr.value + "\n");
}
});
req.endHandler(new SimpleHandler() {
protected void handle() {
System.out.println("end of request");
req.response.end();
}
});
Expand Down
11 changes: 3 additions & 8 deletions src/main/java/org/vertx/mods/formupload/MultipartRequest.java
Expand Up @@ -307,14 +307,9 @@ public void addContent(ByteBuf channelBuffer, boolean last) throws IOException {
}

void attributeCreated() {
if (!getName().equals("name")) {
// Netty has a habit of adding multiple extra attributes of name 'name' and value of the name of the
// real attribute, so we screen these out.
// This is however a problem - what if the user has a real attribute called 'name'?
attributes.put(getName(), getValue());
if (attrHandler != null) {
attrHandler.handle(new Attribute(getName(), getValue()));
}
attributes.put(getName(), getValue());
if (attrHandler != null) {
attrHandler.handle(new Attribute(getName(), getValue()));
}
}
}
Expand Down
Expand Up @@ -4,17 +4,16 @@
import org.vertx.java.core.Handler;
import org.vertx.java.core.SimpleHandler;
import org.vertx.java.core.buffer.Buffer;
import org.vertx.java.core.http.HttpClient;
import org.vertx.java.core.http.HttpClientRequest;
import org.vertx.java.core.http.HttpClientResponse;
import org.vertx.java.core.http.HttpServerRequest;
import org.vertx.java.core.json.JsonObject;
import org.vertx.mods.formupload.Attribute;
import org.vertx.mods.formupload.MultipartRequest;
import org.vertx.testtools.TestVerticle;
import org.vertx.testtools.TestVerticleInfo;

import static org.vertx.testtools.VertxAssert.*;
import static org.vertx.testtools.VertxAssert.assertEquals;
import static org.vertx.testtools.VertxAssert.testComplete;

/*
* Copyright 2013 Red Hat, Inc.
Expand Down Expand Up @@ -75,6 +74,7 @@ public void handle(Buffer body) {
}
});
// The tricky part of this test is working out what needs to be sent to simulate the form.

Buffer buffer = new Buffer("this is the body of the POST");
req.headers().put("content-length", buffer.length());
req.write(buffer).end();
Expand Down

0 comments on commit 80961c9

Please sign in to comment.