I have just started to learn OSGi. Recenly got stuck with an issue. How can I post data
to a HTTP server from an OSGi bundle without using external bundles/framework?
I will like to see code sample of a simple OSGI bundle which acts as a HTTP
client and can send a string to a HTTP server (tornado, in my case).
I have searched around a lot. But I got no direct solutions. There are restlets, Felix and all type of solutions. The only thing I want is to send data from an OSGi bundle to a HTTP server without using any external frameworks. Is it possible?
Please help me out.
Thanks in advance.
Posting data to an HTTP server has nothing to do with OSGi at all, plain Java is all you need.
If you want to go really barebones, you can use an HttpURLConnection to post your data. You can also choose a little more comfort, and use the Apache HttpComponents Client.
Related
We are using nginx server for reverse proxying few micro-services. Every request has Authorization header containing JWT token. Now, what we need to do is extract user details from JWT token and log it on nginx server. Is there anyway to decode and log JWT? I looked into few lua scripts for authenticating request using JWT but that is not what we need. Also, we are trying to avoid using installing Lua on nginx server.
Any help would be greatly appreciated.
EDIT: We are fine with Lua based solution as well.
Relating to your problem and following the comments you could use the official Nginx Plus module to approach in the best way the task:
Authenticating API Clients with JWT and NGINX Plus
But this obviously cost money and in case you want something open-source you should check this project:
TeslaGov /ngx-http-auth-jwt-module
The above module, is working now a days, it's not easy as use the Nginx plus module but it's opensource.
To finish, relating to your Edition, here is a Lua solution.
ubergarm / openresty-nginx-jwt
I am not very into Lua and the project seems to be outdated due it doesn't receive an update since 2018, I share you the link in case you can found something useful from it.
I hope this helps to solve your problem, regards.
I'm writing application which should have build in simple http server for remote control access. I'm using Qt and want to provide to user a way to autentificate.
I've found an http server realisation(by Stefan Frings). Can some one help with solving this problem?
Found the solution myself. It is rather easy by the way....
We just need to add WWW-Authenticate into header and on server side check creditinals.
My web app makes request to third party servers, and we sometimes route them trough proxies. I'd like to be able to "see what they see" -- see what the request looks like once its been routed through the proxy.
Specifically, I'm interested in how much identifying information about the source (my web app) is left in the request once it reaches the destination, having been routed through the proxy.
Does anyone know an easy way to do this? Maybe a web service that will just echo back all the information about the incoming request in the outgoing response?
Not a full answer, but maybe you can try:
http://www.cantoni.org/2012/01/08/simple-webservice-echo-test
And the other 2 webs mentioned there:
http://respondto.it/
http://requestb.in/
To setup a URL to send your requests and see if the info provided helps you.
I'm just stating this as an idea that came to me. You could try sending requests to your own URL, which you control (i.e. a resource in your own web application). That way, you can use your debugging infrastructure or other facilities (basically anything you want) to inspect the request that's coming into your application. It seems to me this might be the most powerful / easiest way to do this. It won't let you test the URL you were trying to test, but in terms of proxy visibility, it might be what you need.
Good luck!
If the proxy supports the TRACE method and the Max-Forwards header you can use that. Not all do, however.
http://myfileserver/images/car/chevrolet.gif
I have this file server holding the files such as images, doc files etc. Now i want to intercept the http request and based on the file extension i want perform some action such as redirection to some other webpage.
What is the best and the easier way to accomplish this thing? I am using asp.net framework for my applications.
Pls suggest the approach.
Thx
If you are looking to intercept the request for specific file types, then go with an Http Handler. Here is the MSDN link explaining their usage - Http Handlers
In the WCF world if you're looking to handle an HTTP request with a different option based on the requested filetype, you may want to look into adding an IDispatchOperationSelector, which allows the service to route the code through a different operation. The default HTTP implementation is the WebHTTPDispatchOperationSelector, which is explained pretty well here and here.
If you want to remain in the Asp.Net world, I'd recomend going with custom message handlers. Here's an article by Mike Wasson explaining how these work & where they fall in the Asp stack.
I have some software which makes a request to a specific URL in internet and I want it to receive my custom response. Is there any software tool for that on Windows? Also it would be nice if I could map a regexp instead of specific URL
Found the solution myself:
Set the domain of the URL to point to 127.0.0.1 in windows hosts file
Install nginx and set it up to show your file for the request response to which you're willing to modify and proxy all other requests to the original server
You could consider writing a test and mocking out the http response with your custom response.
I could give an example using C# and rhino mocks but it's not clear which platform you are working with.
You can:
Try to enject your dll into the process and replace functions like (HttpSendRequest, HttpQueryInfo,...) with your oun versions.
Try to use something like WinPCap (http://www.winpcap.org/).
Fiddler (www.fiddler2.com) has an AutoResponder feature which does exactly that.