Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't retrieve form data with POST and @RequestParam("myParamName") #724

Closed
sixman9 opened this issue May 13, 2016 · 5 comments
Closed

Can't retrieve form data with POST and @RequestParam("myParamName") #724

sixman9 opened this issue May 13, 2016 · 5 comments

Comments

@sixman9
Copy link

sixman9 commented May 13, 2016

@RequestMapping(value = "/reverse", method = RequestMethod.POST, code = 200)
    public void doPostReverse(@RequestParam("reverseParam") String reverseParam, Callback<String> callback) {
        String retval = reverseParam!=null?new StringBuilder(reverseParam).reverse().toString():"reverseParam was NULL";

        System.out.println("In: " + reverseParam + ", Out: " + retval);

    ......

Method parameter 'String reverseParam' is never populated from a form data submission (constructed by Chrome-Postman client), any ideas what I'm doing wrong (qbit 1.6.0)???

The URL _is_ being called, as the 'System.out...' call is executed ("In: null....").

@RichardHightower
Copy link
Member

I will check it out.

@RichardHightower
Copy link
Member

I was able to reproduce it.

@RichardHightower
Copy link
Member

package io.advantageous.qbit.vertx.bugs;

import io.advantageous.qbit.annotation.RequestMapping;
import io.advantageous.qbit.annotation.RequestMethod;
import io.advantageous.qbit.annotation.RequestParam;
import io.advantageous.qbit.http.client.HttpClient;
import io.advantageous.qbit.http.client.HttpClientBuilder;
import io.advantageous.qbit.http.request.HttpRequest;
import io.advantageous.qbit.http.request.HttpRequestBuilder;
import io.advantageous.qbit.http.request.HttpTextResponse;
import io.advantageous.qbit.reactive.Callback;
import io.advantageous.qbit.server.EndpointServerBuilder;
import io.advantageous.qbit.server.ServiceEndpointServer;
import io.advantageous.qbit.util.PortUtils;
import org.junit.Test;

import static org.junit.Assert.assertEquals;

public class Bug724 {

    @RequestMapping("/")
    public static class MyService {
        @RequestMapping(value = "/reverse", method = RequestMethod.POST, code = 200)
        public void doPostReverse(final Callback<String> callback, final @RequestParam("reverseParam") String reverseParam) {
            String retval = reverseParam != null ? new StringBuilder(reverseParam).reverse().toString() : "reverseParam was NULL";
            System.out.println("In: " + reverseParam + ", Out: " + retval);
            callback.resolve("was=" + reverseParam);
        }
    }

    @Test
    public void test() {
        final int port = PortUtils.findOpenPortStartAt(8080);

        final ServiceEndpointServer serviceEndpointServer =
                EndpointServerBuilder.endpointServerBuilder().setUri("/")
                        .addService(new MyService()).setPort(port).build();

        serviceEndpointServer.startServerAndWait();

        final HttpClient httpClient = HttpClientBuilder.httpClientBuilder().setPort(port).buildAndStart();

        final HttpRequest httpRequest = HttpRequestBuilder.httpRequestBuilder().setUri("/reverse")
                .addParam("foo", "bar").addParam("reverseParam", "Rick Loves Java")
                .setFormPostAndCreateFormBody().build();

        final HttpTextResponse httpTextResponse = httpClient.sendRequestAndWait(httpRequest);

        //assertEquals("was=Rick Loves Java", httpTextResponse.body());
    }

}

@RichardHightower
Copy link
Member

We ran into this again.

@RichardHightower
Copy link
Member

Fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants