Can we send body to any route like http post request with payload? - angular2-routing

I have a scenario, I want to hit a route i-e /app/access and with body and i want to access that body like
activeRoute.getBody() in ngOninit.
can we do exactly like this? or any other way to send post params to route and access by active route ?

No we can't. Because every route is HTTP Get and we can't send body / payload to HTTP GET request.
we can't convert the route of angular to POST from GET because this is default behavior of request.
simple we can said that we can't send HTTP Post request to any route or convert any route to HTTP POST route.
If we want to achieve, we have wrap the application to some server side language like Scala and Java or induct any middle wear servlet.

Related

How can I perform an HTTPS POST request that contains a file into the request body using CURL?

I have the following problem.
I have to perform a CURL HTTPS POST REQUEST that put a myFile.xml into the request body toward a specific URL (that shoul represent a web service endpoint), something like: https://XXX.YYY.ZZZ.WWW/myproject/xml/manager
How can I do it using CURL?
I need to do it to simulate a web service call to analyze the obtained request.

How to add cookie to any http.get request in typescript and angular2?

Seems like http.get is forbidden since I don't send the cookie value with the request. If I just surf to the link I will get the response, since the browser send the cookie. How I do the same in typescrip code with angular 2?
Looking at this link:
https://angular.io/docs/ts/latest/api/http/index/RequestOptions-class.html
You can specify RequestOptions (such as header values) with your get request. I presume you could use that to send the cookie in the way you need. There's not much else for information in your question, so I think that's as close as I can get.
Http spec:
https://angular.io/docs/ts/latest/api/http/index/Http-class.html

Get hash tag(#) character of URL in servlet request

I have a URL abc.com/#cancel. In my servlet I need to store #cancel for future use. I have already tried HttpServletRequest getRequestURI() and few other options. But don't see this value in request object. How do I get this value.
In my application I am using GWT which uses rpc calls and rpc request is made based on the hash tag value. eg: mydomain.com/#profile, forwards the request to profile.rpc. In my case I am intercepting this call with a filter which does some basic check and then I want to forward the request again to mydomain.com/#profile. but I am not able to find #profile in request object. Hope this explains my question and what I am looking for.
You cannot get the fragment part of a URL server side, as the browser won't send it to the server.
Eg: User click a link to http://www.example.com/foo#bar. Browser connect to www.example.com and send:
GET /foo HTTP/1.1
Host: www.example.com
Hash(#) is used to separate fragment from Url. Fragment is an optional part of the URL and is used to address a particular part of a resource.
please see below links
http://www.skorks.com/2010/05/what-every-developer-should-know-about-urls/
URL fragment (#) allowed characters
List of valid characters for the fragment identifier in an URL?
request.getRequestURI() will gives you the url eg:abc.com/#cancel.
String url1=request.getRequestURI();
url1.split("/");
Found out that fragmented URL doesn't come in request, when we do response.sedRedirect(), browser doesn't remove the fragmented part from browser URL bar. But not sure how this happens. Anyways in my case instead of posting request to another JSP and then submitting the form to different URL, I am directly doing response.sendRedirect(), which doesn't remove the fragmented part, so its working now :)

Nginx Request Routing based on body param

I am grouping the servers in nginx as explained here. I want to route my requests to different server groups based on the param in request body.
Is there a way I can achieve this ?
If this is a form input sent via POST, then no. The simplest solution is to make the variable sent via GET (incorporate it in the <form> tag's action attribute) or to send it as header.
All variables sent as GET are available via $arg_name. Headers are available through $http_name.

Does REST send its payload in the URL of the request? What about SOAP?

Do SOAP and REST put their respective payloads as a URL? For example:
http://localhost/action/?var=datadatadata
I know SOAP uses XML and sometimes runs on a different port on the server, but do you still submit data like the example above or do you send it as one big XML encapsulated packet to that port?
It depends on your HTTP method. GET method will put everything into URL while POST method only put path information in URL and the rest of them are streamed into the HTTP request body.
SOAP should also rely on HTTP protocol and hence should follow the same rule. Check out http://www.w3.org/TR/soap12-part0/#L10309

Resources