CodeIgniter Curl Library Capturing Error - codeigniter

I am trying to retrieve an error when my CI curl request fails. However, I cant seem to get $this->curl->error_code or $this->curl->error_string to output any data. I am trying to make a request to an API and I am breaking the URL to force an error.
$api_url = "http://breamkebreakmedfd.com";
$this->curl->create($api_url);
$this->curl->execute();
echo($this->curl->error_string);
I get no error when I echo the error.

Related

Trying to handle windows auth with NTLM and Cypress - ‘Username contains invalid characters or is too long’ error

I’m trying to use NTLM plugin with cypress in order to handle windows authentication.
On navigating to my test url the test fails, returning the following error in the cypress test runner ui
‘Username contains invalid characters or is too long’
I’ve verified that my username is correct and can be used manually to access the url.
In my test I’m using the following code to launch the page:
it('should launch the home page with the correct user', () => {
cy.ntlm(['localhost:1234'] , 'XYX\\firstname.lastname', 'Password');
cy.visit('https://localhost:1234')
})
As a string, my username is 'XYX\firstname.lastname'
using this in the code treats the \ as an escape character hence the use of \
I’ve also tried using the url string in the format:
‘https://XYX\firstname.lastname:password#localhost:1234’
But this fails to launch the page
I suspect the problem is something to do to with the \ but im unsure on how to fix this.
Has anyone encountered the error ‘Username contains invalid characters or is too long’ when using ntlm and cypress and what did you do you resolve the issue?

Why is this handler method(/trying) returning the error 404 instead of sending the request to another handler method /addpage

#RequestMapping("/trying")
public String trying(){
return "/addpage";
}
"/addpage" is a request handler method used for handling a request....... But when I try returning "/addpage" from the handler method "/trying" I get the error 404.
How can I solve this...
Make sure that you project is compiling correctly : mvn clean install
The server is starting without errors
remove the "/" to "/addpage" ==> you do not need it if you dont have a path to put other wise ==> "path/to/folder/addpage"

Making a POST request with Chef

I need to post a .json file to a server with a rest API with a Chef recipe, following Chef's documentation I came up with this code:
http_request '/tmp/bpp.json' do
url 'http://localhost:8080/api/v1/blueprints/bpp'
headers ({
'AUTHORIZATION' => "Basic #{Base64.encode64(user)}",
'CONTENT-TYPE' => 'aplication/json'
})
action :post
end
For authorization token, user is a variable that contains 'user:password'
When I run this chef recipe I obtain the following response:
Error executing action `post` on resource 'http_request[POST /tmp/bpp.json]'
Net::HTTPServerException
------------------------
400 "Bad Request"
Prior to this I was just executing a curl call and it was working fine, but I need to change to the http_request resource. This was the old (working) curl request:
curl --user user:password -H 'X-Requested-By:My-cookbook' --data #/tmp/bpp.json localhost:8080/api/v1/blueprints/bpp
I am not very used with REST apis and seems like an uncharted territory to me.
You forget about message. Using file name as resource name won't send this file as data. Try adding:
...
message lazy { IO.read('/tmp/bpp.json') }
...
In your case only the resource name - /tmp/bpp.json, will be sent. Not a file content. As stated in linked doc:
The message that is sent by the HTTP request. Default value: the name of the resource block See “Syntax” section above for more information.

HTTPS using jmeter is not working and getting 403 error

I am load testing an HTTPS service using jmeter.
It works well by using following curl on a linux box:
curl -k -v -HContent-Type:application/json
-HauthToken:abcdefghijkla995e2f9-6cba-46e7-8b08-a7ffb67ca95d20150416163318
-Hsystem_name:testingsystemname -X POST --data-binary '{"deviceId":"1","cookieId":null,"emailId":"jmetertest#gmail.com"}'
https://localhost:9443/service/push/datacheck
How do I use jmeter to hit the request for load testing.
I was putting the authToken and system_name under 'send parameters with request' but it did not work and i keep on getting a 403 error.
Please help
You need to add HTTP Header Manager to your Test Plan and configure it to send the following headers:
authToken=abcdefghijkla995e2f9-6cba-46e7-8b08-a7ffb67ca95d20150416163318
system_name=testingsystemname
For sending JSON switch HTTP Request sampler to "Body Data" tab and put it there.

Getting random "read_nonblock': end of file reached (EOFError)" with Net::HTTP.start

When I execute the following code...
http = Net::HTTP.start('jigsaw.w3.org')
http.request_post('/css-validator/validator', ' ', 'Content-type' => "multipart/form-data")
...then I very often get the following error:
EOFError: end of file reached
from /Users/josh/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/net/protocol.rb:153:in `read_nonblock'
Is this only me? What could be the problem? Sometimes it seems to work, but most of the time it doesn't.
The problem seems to be on the side of the host:
Loading http://jigsaw.w3.org/css-validator/DOWNLOAD.html manually in a browser results most of the time in "no data received" at the moment.
I'm trying to set up the downloadable command line version of the validator on my local machine and use this. More info here: How can I validate CSS on internal web pages?

Resources