Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to read Form Data from headers

In my current application(A), I redirect user to a different website(B) where user logs in with his/her account and finishes some activity and now that website(B) has a button to return my application(A), the redirection happens by posting a SAMLResponse.

When user clicks that button, user return to my application(A) with specific unique user id assigned by that website(B) in "Form Data" of header information.Basically website B is also posting SAMLResponse as a form parameter in a request.

How do I read this request information in php and java?

like image 789
yogsma Avatar asked Nov 20 '13 02:11

yogsma


People also ask

How can I get form data in POST request?

To post HTML form data to the server in URL-encoded format, you need to make an HTTP POST request to the server and provide the HTML form data in the body of the POST message. You also need to specify the data type using the Content-Type: application/x-www-form-urlencoded request header.

How do I find my FormData value?

The get() method of the FormData interface returns the first value associated with a given key from within a FormData object. If you expect multiple values and want all of them, use the getAll() method instead.

How do I get node js form data?

To get started with forms, we will first install the body-parser(for parsing JSON and url-encoded data) and multer(for parsing multipart/form data) middleware. var express = require('express'); var bodyParser = require('body-parser'); var multer = require('multer'); var upload = multer(); var app = express(); app.

How do you use form data?

FormData objects are used to capture HTML form and submit it using fetch or another network method. We can either create new FormData(form) from an HTML form, or create an object without a form at all, and then append fields with methods: formData. append(name, value)


1 Answers

The "form data" part is unclear, but you can print the source code of your desired url/form to the console like this:

import java.io.*;
import java.net.*;

public class Client {

 public String getHTML(String urlToRead) {
  URL url;
  HttpURLConnection conn;
  BufferedReader rd;
  String line;
  String result = "";
  try {
     url = new URL(urlToRead);
     conn = (HttpURLConnection) url.openConnection();
     conn.setRequestMethod("GET");
     rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
     while ((line = rd.readLine()) != null) {
      //basically makes a huge string
         result += line;
     }
     rd.close();
  } catch (Exception e) {
     e.printStackTrace();
  }
  return result;
 }

public static void main(String args[])
{
  Client c = new Client();
 System.out.println(c.getHTML("YOUR URL HERE"));
 //prints source code to console

}

//from here, you need to know which item you want to do is at which index of the string
}
like image 194
prouvaire Avatar answered Sep 22 '22 03:09

prouvaire