Win a copy of Spring in Action (5th edition) this week in the Spring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Ganesh Patekar
  • Frits Walraven
  • Tim Moores
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Stephan van Hulst
  • salvin francis
  • Tim Holloway

How can intercept one HTTP request and modify the URL parameter?  RSS feed

 
Ranch Hand
Posts: 451
6
Netbeans IDE Oracle Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I want to intercept one http request (get) and modify one parameter send by url parameter.

I read that there are the interface httpintercept but I don't know how can modify the parameter send by url parameter.

So, URL : http://site/api/rest?k=yyyyyyyyy.

I wanted to send http://site/api/rest?k=vvvvvvvv.

Can someone help me?

Thanks in advance
 
Sheriff
Posts: 21464
97
Chrome Eclipse IDE Java Spring Ubuntu VI Editor Windows
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is this on the client or on the server? And what libraries / frameworks are you using? For instance, does this need to be done in a servlet environment, or when using URLConnection, or when Apache's HttpClient, etc...
 
Dana Ucaed
Ranch Hand
Posts: 451
6
Netbeans IDE Oracle Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It is about a call on client and you can user JS or TypeScript,

 
Dana Ucaed
Ranch Hand
Posts: 451
6
Netbeans IDE Oracle Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can use URLConnection or Apache HTTP.
 
Saloon Keeper
Posts: 2150
278
Android Angular Framework Eclipse IDE Java Linux MySQL Database Redhat TypeScript
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Dana Ucaed wrote:I read that there are the interface httpintercept but I don't know how can modify the parameter send by url parameter.


You are talking about Angular HttpInterceptor interface - right?
 
Dana Ucaed
Ranch Hand
Posts: 451
6
Netbeans IDE Oracle Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yep.

 
Ranch Hand
Posts: 92
AngularJS Chrome Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
We cannot directly modify the request URL in intercept method, Since url is const in HttpRequest

We need to close the request object and modify URL something like below.

 
Saloon Keeper
Posts: 5038
134
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Dana Ucaed wrote:You can use URLConnection or Apache HTTP.


These are Java classes/libraries - that contradicts your assertion that it is about Angular (or "JS or TypeScript") - please clarify.
 
Dana Ucaed
Ranch Hand
Posts: 451
6
Netbeans IDE Oracle Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I need for Java and / or TypeScript.

 
Dana Ucaed
Ranch Hand
Posts: 451
6
Netbeans IDE Oracle Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to add some clarifications.

When in a app I did the request : https://numesite.com?key=llllll and want to modify the value of key.

Thanks.

 
Dinesh Kumar Ramakrishnan
Ranch Hand
Posts: 92
AngularJS Chrome Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can use regex match or string replace to do this in the interceptor

Dinesh Kumar Ramakrishnan wrote:We cannot directly modify the request URL in intercept method, Since url is const in HttpRequest

We need to close the request object and modify URL something like below.

 
Dana Ucaed
Ranch Hand
Posts: 451
6
Netbeans IDE Oracle Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I appreciate your response.

 
What a show! What atmosphere! What fun! What a tiny ad!
Download Free Java APIs to Work with Office Files and PDF
htttp://www.e-iceblue.com/free-apis.html
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!