Guzzle: how to intercept a meta Refresh - page-refresh

I'm using Guzzle to get the HTML of a webpage that on the domain has set a meta Refresh:
<meta http-equiv="Refresh" content="1;URL=http://www.example.com/sub_folder/" />
Guzzle seems not intercept this kind of redirect. Is it correct? Can I configure Guzzle to follow the refresh?
Which other solutions should can I consider to solve the problem and make Guzzle follow the refresh?

I had the same issue. I created script that manyally follows such redirect. Symfony DomCrawler is great tool to extract meta and parse meta value.

Related

how to restrict html tags in query string in mvc

how to handle request when user directly enters html content in URL.
I want to redirect to Error page when user enters html tag in URL is that possible in MVC.
I have tried from BeginExecute event of by creating override method.
Please give some suggestion.
Thanks.
meybe can use RouteHandler for when a user needs to redirect to any
external page, shorten long URLs, or make URLs more user friendly.
please check my answer
Error handling ASP.NET MVC
You can always choose CustomErrorMode="On" in web.config and configure with your error controller
Custom Error Mode will help you to redirect any invalid or malicious link or content to redirect it to your errorcontroller and handle it the way you want.
You can use Request validation for do it. It prevents to accept un-encoded HTML/XML etc from Client to server. It validates all the data that is passed from client to server. To use this feature , you must set requestValidationMode as 4.5 in web.config like:
<httpruntime requestvalidationmode="4.5" />
For more information please see this article.

How to redirect a page in sightly without html tags. Apart from "meta" command

I need to know about the redirection happen in sightly. Can someone help me with the code. I dont want http://www.indiana.edu/~account/new-directory"> as this will be configured in head of html.
For me requirement in sightly.
Sightly is a templating language only!
If you want a redirect, implement it in your controller Java class.
See Request Response API for that. https://docs.adobe.com/docs/en/cq/5-6-1/javadoc/org/apache/sling/api/SlingHttpServletResponse.html
The WCMUse classes have access to the response object, here is the API : https://docs.adobe.com/docs/en/aem/6-0/develop/ref/javadoc/com/adobe/cq/sightly/WCMUse.html
The redirection after that is just pure Java Servlet redirection.
Hope this will help.

Tsung Load Testing for Ajax request

I'm writing a config file for Tsung load testing the application. I want to write a request that can simulate clicking a button on the page. I know that this is usually done by something like this
<request>
<http url='/' version='1.1' method='GET'></http>
</request>
But this link makes an ajax request and then return to this page so I'm not sure how to simulate this behavior. How should I go about this?
Thank you so much in advance!
The best way to do this is to look at all requests generated with your browser dev tools collection, like Firebug for example.
If you want to test an ajax call it's the same as calling a classical page for tsung, so first write a <request> with the url of your page, add a <thinktime>, and add another <request> with the url of your ajax ressource.

Spring-Security with /j_spring_security_logout possibly not logging out fully

So I am trying to determine if this is a bug or browser caching or if I am missing something, but when I log out I can access any page that I have previously accessed before. I even have an ajax call to a rest endpoint and when I call that I print the response and get a 200 ok.
Now if I click logout it returns to the login page with the invalid session url params. So it looks like it is attempting to remove the session, plus if I close the browser fully, not just the tab I can no longer access the pages I was able to access before. But if I don't close the browser I can access any pages that I have already accessed, pages I have not accessed yet forward me to the login page. It makes me wonder if its a browser cache issue, but the 200ok on the ajax request makes me doubt that.
Spring-Security version 3.1.0
Here is my configuration for the logout.
<logout invalidate-session="true" logout-success-url="/login-page.html?logout=true"
logout-url="/j_spring_security_logout" />
<session-management invalid-session-url="/login-page.html?session=invalid">
<concurrency-control max-sessions="1" error-if-maximum-exceeded="true" />
</session-management>
in the web.xml i have added this listener
<listener>
<listener-class>org.springframework.security.web.session.HttpSessionEventPublisher</listener-class>
</listener>
UPDATE
It was indeed a browser cache issue, so to fix it I added to the DispatcherServlet xml
<bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter">
<property name="cacheSeconds" value="0" />
</bean>
Also added the META tags to head
<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="Expires" content="-1">
This now disables caching for all my pages and rest methods.
Indeed it really looks like a caching issue:
Try accessing already visited pages with some extra random parameter
...try the same with AJAX call (just append ?random= + Math.random().
Also try POSTing using AJAX, as GET is much more likely being cached.
Finally have a look at Firebug or any other monitoring tool (or access log on the server side) to confirm the request was cached. If caching is the problem, investigate why browser decides to cache your resources.

oauth application for msn domain name for call back url

i am doing a project on oauth for different providers.MSN live is one of them.
i have used the scribe oauth code for all of the providers. For google,twitter,facebook,linkedin i am able to get the callback url as http://localhost:8080/ and it is returning well with the verification code.
But with the MSN it is asking the domain name(it is not allowing me to type the localhost:url and it is asking clerly that i should give valid domain name while in registration.
So i gave my blogsite name as valid url.
when i run my application i am getting callback as http:myname.blogspot.in/code="somecode"
Now i should use the code dyanamically in programming to verify the code so that i get the user resources.
Alternatively can we change our localhost application to domain application so that in the registration of the msn site also it should show valid domain and we can get the data from msn to our localhost application.
Some steps are given in the following link
http://complete-concrete-concise.com/web-tools/how-to-change-localhost-to-a-domain-name
But the fake url (means the localhost application which is converted as domain url).....can it be identified by msn as valid domain is still not understandable.
if anybody has some knowledge on this, can you some light on this.
Thank you in advance.
This is simple after Mr.Umesh Awasthi gave the clue.
Firstly,go to the below site.
http://24sevenpost.com/tech-gizmo/windows-7-step-step-guide-edit-hosts-file-system32/
take a new line the hosts file and type like this.
127.0.0.1 www.babc.com
then you have your own domain.
Give the domain name as http://www.babc.com:8080/ in the registration form domain name text box.
Thats it.
run the apache tomcat
run the application.
you will get a message like this. www.babc.com:8080/code="somecode"
Thank you.
But i have small problem. i have to give the Url for protected resources.
i have tried with giving the url as https://apis.live.net/v5.0/me
400
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN""http://www.w3.org/TR/html4/strict.dtd">
<HTML><HEAD><TITLE>Bad Request</TITLE>
<META HTTP-EQUIV="Content-Type" Content="text/html; charset=us-ascii"></HEAD>
<BODY><h2>Bad Request - Invalid URL</h2>
<hr><p>HTTP Error 400. The request URL is invalid.</p>
</BODY></HTML>
i do not understand what the problem exactly is.Is my urls for resources not a correct urls?
can anybody help me in this......

Resources