HTTP 400 of "AAAy H.mp3" but not "AAAy L.mp3" - http

Ok, this is weird, and I can fix it by getting rid of spaces, but what is going on?
I have two files on my website, AAAy H.mp3 and AAAy L.mp3. I can browse to them just fine.
When I do:
curl "http://mikehelland.com/omg/AAAy L.mp3"
I get the mp3 file.
When I do:
curl "http://mikehelland.com/omg/AAAy H.mp3"
I get 400, bad request. Also doing:
curl "http://mikehelland.com/omg/AAAY H.mp3"
yields a 400.
Change the H to an L or A or M or anything else seems to work fine. What's going on?

This is because of how server interprets space in file name, try to replace it with %20 (which represents space symbol in url) like this:
curl "http://mikehelland.com/omg/AAAy%20H.mp3"
If you try to acess your file with browser and will open developer console, you will found that browser inserts this %20 in GET request. So it is the reason why you can access file with browser, but not from terminal.
Also, try to add --verbose option to curl command. I noticed that when you access some inexistent file without space in name, the is the field in response 'Server: Apache/2', but when you add space it is 'Server: nginx'.
So maybe there is special case when server stops handling requset because it can't distinguish what to do with first line in request
GET /omg/AAAy H.mp3 HTTP/1.1
because it expects HTTP/1.1 after /omg/AAAy, but not weird H.mp3. And maybe server looks at first symbol in "H.mp3" when parse for HTTP, and it made things broken. So I think the reason why "/omg/AAAy H.mp3" doesn't work, but "/omg/AAAy L.mp3" works is due to parsing mechanism of the server. Of course, without %20 all variants are forbidden by standard.

Related

CURL command not working with simple HTTP GET but browser does

I tried to fetch the data from https://m.jetstar.com/Ink.API/api/flightAvailability?LocaleKey=en_AU&ChildPaxCount=0&DepartureDate=2016-03-21T00%3A00%3A00&ModeSaleCode=&Destination=NGO&CurrencyCode=TWD&AdultPaxCount=1&ReturnDate=&InfantPaxCount=0&Origin=TPE
it couldn't be done by curl -vv https://m.jetstar.com/Ink.API/api/flightAvailability?LocaleKey=en_AU&ChildPaxCount=0&DepartureDate=2016-03-21T00%3A00%3A00&ModeSaleCode=&Destination=NGO&CurrencyCode=TWD&AdultPaxCount=1&ReturnDate=&InfantPaxCount=0&Origin=TPE it will return nothing,
However, browser can fetch whole data.
What's wrong with that?
It seems to me that "m.jetstar.com" is filtering requests that don't include the headers that a browser would send. Your curl statement needs to fully emulate a browser to get the data. One way to see what I'm saying is to open developer tools in Google Chrome, select the network tab, run the URL in the browser then goto to the row indicating the call and right click, then copy the request as a curl statement, then paste it to a notepad and you'll see all the additional headers you need. Additionally, that curl statement should work.
check if you have set any HTTP_REQUEST variable for proxy settings. Verify by calling curl command in verbose mode. curl -v
I had setup a variable earlier and when I check the curl output in verbose mode it told me that it was going to proxy address. Once I deleted the HTTP_REQUEST variable from advanced system settings, it started working. Hope it helps.

TinkerPop3 rest test via browser

I am getting the valid response while made curl request :
bin/gremlin-server.bat conf/gremlin-server-rest-modern.yaml
curl "http://localhost:8182?gremlin=100-1"
curl "http://localhost:8182?gremlin=g.V()"
But via browser I am getting the below massage :
{"message":"no gremlin script supplied"}
Also tried as below but no result:
http://localhost:8182/gremlin?script=g.V()
http://localhost:8182/graphs/tinkergraph/tp/gremlin?script=g.traversal().V()
http://localhost:8182/graphs/tinkergraph/tp/gremlin?script=g.V()
Any suggestion on what is the valid way of passing script via browser.
I'm not sure this is a "bug" exactly, but Gremlin Server didn't respect very complex ACCEPT headers. For example, when I try to resolve one of your first two URLs in Chrome, I get:
{
message: "no serializer for requested Accept header: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8"
}
By default, Gremlin Server doesn't support that ACCEPT. If the browser had requested application/json or simply *.* it would work. Note that *.* is present with quality 0.8, but Gremlin Server wasn't parsing the header that way to determine that. As a result, it couldn't find the serializer to properly deal with that.
There is no workaround for the browser that I know of. I've created an issue to get this fixed:
https://issues.apache.org/jira/browse/TINKERPOP3-752
I've also seen this error when I have forgotten to start cassandra before starting gremlin-server.
My problem was due to the presence of spaces in the request.
This worked;
curl http://localhost:8182/?gremlin="g.V().has('name','foody')"
but this didn't;
curl http://localhost:8182/?gremlin="g.V().has('name', 'foody')"
Try removing them from yours and they should work.
I found the answer thanks to your question, so I will pitch for the right answer for #stacey-morgan:
You queried on the CLI:
curl "http://localhost:8182?gremlin=100-1"
Then you may have queried (as it is not clear from your question)
http://localhost:8182/gremlin?script=100-1
Or the others you have done, just as I was doing:
http://localhost:8182/gremlin?script=g.V()
You would get the error message.
The correct way of doing it just paste the content of the "" from the curl command. So
http://localhost:8182?gremlin=100-1
Then similarly for your other queries:
http://localhost:8182/?gremlin=g.V()
http://localhost:8182/?gremlin=g.traversal().V()
Note: trailing slash should be there though it works without it on my FF. That is HTTP.
Using: Ubuntu & Titan1.0.0-hadoop1.

passing http url as an get method variable - how to?

I am trying to do this:
http://somehost.net/edit.php?url=http://www.youtube.com/watch?v=EgHY53dOZ-U
Forbidden
You don't have permission to access edit.php on this server.
Is there a way to fix this through javascript(jquery), cause I am passing argument through ajax call.
I have tried it this way but without success:
$('#videofrm').load('edit.php?url='+encodeURI($(this).siblings('a').attr('href'))
You should fix the chmoding issues on the server.
Edit
What your edit.php doing ? If it redirecting to somewhere else ? then echo the result url before redirecting.
You can follow Tomalak Geret'kal if you want/can rewrite the .htaccess. otherwise you need to pass the url without the http:// part and prepend an http:// on edit.php
If you don't have permission to access edit.php, then it doesn't matter how many different ways you try to request it: you don't have permission.
Fix the permissions on the server, likely using chmod if the server is on Linux.
Update
You have a server configuration issue. I can only replicate the problem when passing the string :// inside the querystring.
Try writing AllowEncodedSlashes On in your httpd config, as per this question/answer.
You will then need to make sure you encode your URI properly:
http://somehost.net/edit.php?url=http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv=EgHY53dOZ-U
(it looks like your encodeURI call should take care of that part)
AllowEncodedSlashes allows slashes to be present in the query string as long as they're encoded which, for some reason, is not the case by default. The docs say that failure produces a 404, not a 403, but I still think that this is the cause.
If you are not able to manipulate configuration options for your webserver, workarounds include:
Choosing a stand-in term for http:// like http!!! that you will programmatically revert in the PHP script;
If you always use http:// (as opposed to, say, ftp:// or some local path), just leave it off the query string entirely and prepend it to the input in your PHP script (preferred workaround).
Hope that helps.

Could it be that the google url shortening api key works only on 1 computer?

I'm using the Google URL Shortener from an ASP.NET website. It works
fine from my localhost, but on the test server I get the following
error:
System.Net.WebException: The remote server returned an error: (403)
Forbidden.
at System.Net.HttpWebRequest.GetResponse()
at GoogleUrlShortnerApi.Shorten(String url)
I'm using the exact code that is shown here:
http://www.jphellemons.nl/post/Google-URL-shortener-API-%28googl%29-C-sharp-class-C.aspx
Could it be that the key works only on my local computer, and not any other computer? I have obtained another key (using another Google account), but this one gives me the same error (403) both on my local computer, and on the test server.
I doubt very much the API is linked to a particular PC. You need to check the requests - both the URL and headers - that your program is sending out, they must be different in some way. Is your server behind some kind of proxy - e.g Apache? If not configured right this might also be mangling the request. Also make sure your requests are encoded correctly.
I made a few modifications, according to a tutorial by Scott Mitchell, and I change the following lines of code:
First, Instead of:
string post = "{\"longUrl\": \"" + url + "\"}";
I used:
string post = string.Format(#"{{""longUrl"": ""{0}""}}", url );
Second, I commented out these 2 lines:
request.ServicePoint.Expect100Continue = false;
request.Headers.Add("Cache-Control", "no-cache");
I don't know why, but suddenly it started working. So I wanted to see which of the 3 thins I did made the problem, so I returned each one, and - TADA - it still works, even with all 3 back there! So I really don't know what caused the problem, but since the code work without those 2 commented out lines, and the other modification, I am leaving it that way.
I hope this answer will help someone sometime...

How to use http-delete from the shell

Is it possible to send a HTTP DELETE request from the shell and if so, how?
curl -X delete URL
see (google cache, server seems slow) reference.
There are probably a lot of tools to do this, but the easiest, if you don't want to make sure those tools are available, might be to manually create your DELETE-request and send it to the server via telnet. I think the syntax is pretty much like this, although I've never used the delete command manually myself, only get and post.
DELETE /my/path/to/file HTTP/1.1
Host: www.example.com
Connection: close
There should be an extra newline (blank line) after the request to terminate it, but markdown won't allow me to do that. Store that in a file (or paste it in the console, if you don't want to use a script), then simply do
telnet www.example.com 80 < myRequest.txt
Of course, you can use a here-document as well.

Resources