Unit Test Laravel’s FormRequest

I found a good solution on Laracast and added some customization to the mix. The Code /** * Test first_name validation rules * * @return void */ public function test_valid_first_name() { $this->assertTrue($this->validateField(‘first_name’, ‘jon’)); $this->assertTrue($this->validateField(‘first_name’, ‘jo’)); $this->assertFalse($this->validateField(‘first_name’, ‘j’)); $this->assertFalse($this->validateField(‘first_name’, ”)); $this->assertFalse($this->validateField(‘first_name’, ‘1’)); $this->assertFalse($this->validateField(‘first_name’, ‘jon1’)); } /** * Check a field and value against validation rule * … Read more

Is there a static way to get the current HttpServletRequest in Spring

If you are using spring you can do the following: public static HttpServletRequest getCurrentHttpRequest(){ RequestAttributes requestAttributes = RequestContextHolder.getRequestAttributes(); if (requestAttributes instanceof ServletRequestAttributes) { HttpServletRequest request = ((ServletRequestAttributes)requestAttributes).getRequest(); return request; } logger.debug(“Not called in the context of an HTTP request”); return null; }

What happens when no response is received for a request? I’m seeing retries

Checkout this blog post that explains what is happening: http://geek.starbean.net/?p=393 According to HTTP/1.1 RFC 8.2.4: If an HTTP/1.1 client sends a request which includes a request body, but which does not include an Expect request-header field with the “100-continue” expectation, and if the client is not directly connected to an HTTP/1.1 origin server, and if … Read more

struts2 file upload loosing parameters

Problem solved ! From the updated documentation, now the problem can be solved by using the new JakartaStreamMultiPartRequest : As from Struts version 2.3.18 a new implementation of MultiPartRequest was added – JakartaStreamMultiPartRequest. It can be used to handle large files, see WW-3025 for more details, but you can simple set <constant name=”struts.multipart.parser” value=”jakarta-stream” /> … Read more

Volley – how to send DELETE request parameters?

Same problem here but I found the solution. The problem is the implementation of the createHttpRequest method in com.android.volley.toolbox.HttpClientStack.java which will add the body only if the request method is POST, PUT or PATCH. /** * Creates the appropriate subclass of HttpUriRequest for passed in request. */ @SuppressWarnings(“deprecation”) /* protected */ static HttpUriRequest createHttpRequest(Request<?> request, … Read more