How long can GET URL #anchor be? - url

I'm trying to encode the state of webpage in #anchor by base64 encoding JSON string. Sometimes this string gets very long, 10KB for example. I'm not certain I can keep all this data in #anchor.
Does anyone know if #anchor is part of URL length definition?
If it is then is it 2048? or is it 4096? There are conflicting answers about URL length.
If it isn't then how much data can I put in #anchor?

Related

Passing "%20" into a string to be encoded as a URL without it converting to a space?

I have the following code to post data to a site: https://play.golang.org/p/e1g0Nd1kDh0
When I view the request in Fiddler, it shows as:
"jobTitle=Area Manager"
What I want it to do is send the string exactly as it is in the code (i.e. not encode the %20 to spaces), as it seems to be causing some confusion on the other side? An identical request made using a Python program works fine where the spaces are not added.
I've tried escaping it by doubling the % signs, but it doesn't seem to work. Any help would be great.
Thanks.
If you're trying to receive a literal %20 on the server side, then encode the % sign. It encodes to %25. So your postdata becomes:
data := "&jobTitle=Area%25%20Manager"
But if this is happening, there is probably a problem on the server side where the postdata is being decoded twice.
You can also pass the URL encode characters individually. In this case %25%32%30 = "%20"

Use base64 encoded string in url cakephp

here is the solution for php Passing base64 encoded strings in URL
but because of urlencode cakephp problem I cant use it (the solution in there is not good for me)
Passing an urlencoded URL as parameter to a controller / action at CakePHP
Rawurlencode does not work either. Also I cant hash it because I need it to be reversible. Or is there some "reversible" hash function. I know that the meaning of hash is for one way, but like some way to get output similar(so I can use in the url without problems) to md5/sha* but be able to reverse.
QSN: how to use base64 encoded string in url to avoid problems, mentioned in the above link.

JSoup does not post data in ISO 8859 encoding

Is there any way to tell JSoup to post data using iso-8859-1 rather than utf-8 ?
I tried posting a parameter that contains the letter 'è' the my webserver receives the character with hex code C3A8 but I want to send E8.
The code I wrote is
Document document = Jsoup.connect("https://somesite.com/test") .data("parameter1","\u00E8").
header("Content-Type","application/x-www-form-urlencoded;charset=UTF-8")
.method(Method.POST)
.execute()
.parse();
As already said, on the other hand I get a 2 bytes data (C3A8) rather than a single byte with E8 inside.
Thanks in advance for your help.
Trying to replicate a successful POST request with JSoup - data posted to server does not get decoded
Has an accepted answer, saying it is not possible to do it. You will have to find a way to post your code into utf-8. If you do not succeed in that, just open a new question about it.

How this URL will be decoded - Confusion in basic Http Get

Basically I need to pass three paramaters to a http as get. Here are the parameters
param1 = 3
param2 = 454
param3 = http://localhost:3000/another_test?another_param=4&another_param2=978
This transforms to
http://localhost:3000/test?param1=3&param2=454&param3=http://localhost:3000/another_test?another_param=4&another_param2=978
I am just confused whether the URL formed is correct or not. Will this work or is there anyother way to do this. I am using Rails. I did a decode and clicked on the link and I still see the above URL coming. Will this work on the receiever side, meaning will it be decoded as I had intended.
Please advise.
It should work as long as you url encode the params. In that case the & and ? will be transformed, making it possible for Rails to differentiate between the query string parameters and the query string delimiters.
To ensure that it is encoded you can use Rack::Utils.escape or Hash#to_query.
This will be decoded as:
param1=3
param2=454
param3=http://localhost:3000/another_test?another_param=4
another_param2=978
You need to encode param3, or at minimum replace the ampersands in it with the correct URL encoding, in order for it to match back up to your input parameters.

Translate binary characters to a human readable string?

So let's say we have a string that is like this:
‰û]M§Äq¸ºþe Ø·¦ŸßÛµÖ˜eÆÈym™ÎB+KºªXv©+Å+óS—¶ê'å‚4ŒBFJF󒉚Ү}Fó†ŽxöÒ&‹¢ T†^¤( OêIº ò|<)ð
How do I turn it into a human readable string of chars, cuz like it was a wierd output of HTML from a webserver that is text I think cuz half the web page loaded correctly. Do I need to read it with like C or Python or something. That's only a snippet of the string.
If that is in fact supposed to be a human-readable string, you'll need to figure out what character encoding it uses and translate. It's also possible that the string is compressed, encrypted, or represents binary data. It would be helpful to know where you got your string from.
I'm guessing your web server isn't sending the correct mime-type. I'd suggest taking a look at the http headers using Firefox's Live Headers plugin. If a web server decides to send you a pdf, but doesn't set the mime-type, you'll just see garbage on your screen. Alternatively, save the page to a file, and then run these commands from Cygwin or a unix shell:
file mypage.htm
strings mypage.htm
The first will tell you if the header bytes follow any recognizable pattern. The second will strip out and display all the human readable text.

Resources