This question already has answers here:
How to get the URL fragment identifier from HttpServletRequest
(2 answers)
Closed 6 years ago.
Say i make a get request like this:
GET http://cotnet.diggstatic.com:6000/js/loader/443/JS_Libraries,jquery|Class|analytics|lightbox|label|jquery-dom|jquery-cookie?q=hello#frag HTTP/1.0
Host: cotnet.diggstatic.com:6000
My servlet takes request like this:
HttpServletRequest req;
When i debug my server and execute, i get the following:
req.getRequestURL().toString() = "http://cotnet.diggstatic.com:6000/js/loader/443/JS_Libraries,jquery%7cClass%7canalytics%7clightbox%7clabel%7cjquery-dom%7cjquery-cookie"
req.getRequestURI() = "/js/loader/443/JS_Libraries,jquery%7cClass%7canalytics%7clightbox%7clabel%7cjquery-dom%7cjquery-cookie"
req.getQueryString() = "q=hello"
How does one get the fragment information ?
Also, when i debug the request, i see a uri_ field of type java.net.URI which has the fragment information. This is exactly what i want. How can i get that ?
"The fragment identifier functions differently than the rest of the URI: namely, its processing is exclusively client-side with no participation from the server." Wikipedia about the Frament Identifiert
For further reference see the RFC 2394 Section 4.1
Related
This question already has answers here:
Can I read the hash portion of the URL on my server-side application (PHP, Ruby, Python, etc.)?
(12 answers)
How to get Url Hash (#) from server side
(6 answers)
Closed 1 year ago.
Hi after redirection from OAuth server, I am unable to get the complete URL in my JAVA Servlet.My URL looks like below -
https://host.vp.com/gui/MainPage.gdi#scope=openid%20profile&id_token=eyJ0eXAiOiJKV86sada0ajdasJUUEB343KHFKK
I tried request.getRequestURL() , request.getRequestURL(), request.getPathInfo(), no luck in getting the part of the URL which starts after #, i.e., scope=openid%20profile&id_token=eyJ0eXAiOiJKV86sada0ajdasJUUEB343KHFKK, Can someone help me here?
Your Query string should start with ? instead of # to be able to read in the Selvlet.
This question already has an answer here:
Karate API Testing - Reusing variables in different scenarios in the same feature file
(1 answer)
Closed 2 years ago.
This is a followup from a previous question I asked Using response data from one scenario to another
I am looking to take information from a response in one url, then use it in a second url for another assertion.
Something like this:
Scenario: Search for asset
Given url "https://foo.bar.buzz"
When method get
Then status 200
* def responseItem = $.items[0].id // variable initialized from the response
Given url "https://foo.bar.buzz/" + responseItem + "/metadata"
// making request payload
When method put.....
Right now when I run this, it gets hung up on the second Given statement.
Any thoughts on how to resolve this?
As you probably figured out, the "Karate HTML report" will show you the request/response and headers, as long as you put DEBUG log level in your log4j config, and that will answer your question.
first of all i asked something before and i got another question
please take a look this one first
I send some values to another url and about that
i made a question and got an answer, and finally i have another question
if like i said that above question, i send some values to other url
using spring and httpclient like this,
HttpClient client = HttpClientBuilder.create().build();
HttpPost post = new HttpPost("http://test.com");
post.setEntity(new UrlEncodedFormEntity(values arrayList));
(values arrayLists that i made is
arrayList.add(new BasicNameValuePair("name","mister"));
HttpResponse response = client.execute(post);
if i send some value like that,how i get http status value at the receiving page, "http://test.com" if i assume that receiving page using spring and java
how to code to get http status value?
please answer my question regarding the implementation of the following method in Google Translate .net api v2:
How many characters can be sent as a string with this method at most?
var response = service.Translations.List(source, targetLanguageCode).Execute();
I have searched the Internet and found a general answer which is as follows:
The maximum length of a request as GET is 2000 characters, whereas it is 5000 characters as POST. However, this rule does not appear to be true about this library. Using this method for instance, I could send and translate a string as long as 19500 characters; however, I sometimes encountered the following error:
Invalid Uri: The Uri string is too long
Thanks
--EDITED
I was wrong about POST size limitation. Based on this link and other resources, there is no limitation.
http://www.w3schools.com/tags/ref_httpmethods.asp
This question already has answers here:
What exactly is an HTTP Entity?
(10 answers)
Closed 9 years ago.
Now I know what's an http entity. But what's entity used for?
I mean, when an application manipulates an http request or response, it just need to know how to parse message head and message body. Then what's the role of an entity? They have almost similar structures.
I dont really understand what you are trying to ask?
If you mean can we skip using HttpEntity in response and request at all? The answer is no!
its a convention you have to follow it, that how internet works!
Quoting entities from apache documentation:
Since an entity can represent both binary and character content, it
has support for character encodings (to support the latter, ie.
character content).
The entity is created when the request was successful, and used to
read the response.
To read the content from the entity, you can either retrieve the input
stream via the HttpEntity.getContent() method, which returns an
InputStream, or you can supply an output stream to the
HttpEntity.writeTo(OutputStream) method, which will return once all
content has been written to the given stream.
When the entity was received as a result of a response, the methods
getContentType() and getContentLength() methods are for reading the
common headers Content-Type and Content-Length respectively (if they
are available). Since the Content-Type header can contain a character
encoding for text mime-types like text/plain or text/html, the
getContentEncoding() method is used to read this information. If the
headers aren't available, a length of -1 will be returned, and NULL
for the content-type. If the Content-Type header is available, a
[Header] object will be returned.
When creating an entity for a request, this meta data has to be
supplied by the creator of the entity.
Other headers from the response are read using the getHeaders()
methods from the response object.
Source: http://wiki.apache.org/HttpComponents/HttpEntity
And I'm again sorry if I didn't get your question right, but hope this helps anyways.